Reputation: 121
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("sms_body",sMessage);
startActivity(smsIntent);
It is working fine. But I want to open non editable message body. User can only select the number to whom he/she wants to send the message
Upvotes: 0
Views: 246
Reputation: 1095
You can try different way then intent.Like using directly sms to recipient's number and display the message in your own view.
Code to send SMS directly to phone number :
private void sendAutoSms(String phonenumber,String message, boolean isBinary)
{
SmsManager manager = SmsManager.getDefault();
PendingIntent intentSend = PendingIntent.getBroadcast(this, 0, new Intent(SMS_SENT), 0);
PendingIntent intentDelivered = PendingIntent.getBroadcast(this, 0, new Intent(SMS_DELIVERED), 0);
if(isBinary)
{
byte[] data = new byte[message.length()];
for(int index=0; index<message.length() && index < MAX_SMS_MESSAGE_LENGTH; ++index)
{
data[index] = (byte)message.charAt(index);
}
manager.sendDataMessage(phonenumber, null, (short) SMS_PORT, data,intentSend, intentDelivered);
}
else
{
int length = message.length();
if(length > MAX_SMS_MESSAGE_LENGTH)
{
ArrayList<String> messagelist = manager.divideMessage(message);
manager.sendMultipartTextMessage(phonenumber, null, messagelist, null, null);
}
else
{
manager.sendTextMessage(phonenumber, null, message, intentSend, intentDelivered);
}
}
}
Include Permission in manifest
<uses-permission android:name="android.permission.SEND_SMS"/>
Upvotes: 2