0

I am using the below code to call an MMS intent :

{
Intent mmsIntent = new Intent(Intent.ACTION_SEND);
mmsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mmsIntent.putExtra("address", temp);
mmsIntent.putExtra("sms_body", msgstr);
mmsIntent.putExtra(Intent.EXTRA_STREAM, mediaUri);
}

Here 'temp' is the string containing multiple numbers and differentiated with ';'. It's working fine when we use this code for only a single number but when i add multiple numbers it doesn't attached to the messaging app. I have tried the same thing with ',' to separate the phone numbers but it also doesn't work. Any help is appreciated.

Bhavik Tikudiya
  • 103
  • 1
  • 7

2 Answers2

0
Intent mmsIntent= new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:9858254511;9858526521"));
mmsIntent.putExtra("sms_body", msgstr);
mmsIntent.putExtra(Intent.EXTRA_STREAM, mediaUri);
startActivity(smsIntent);

Add a semicolon delimited list of phone numbers to "smsto:" as the URI in the Intent constructor. Also refer this LINK

Community
  • 1
  • 1
dipali
  • 10,966
  • 5
  • 25
  • 51
0
protected void sendMsg(Context context, SmsMessage smsMessage) {
        SmsManager smsMgr = SmsManager.getDefault();
        ArrayList<string> smsMessageText = smsMgr.divideMessage(smsMessage.getMsgBody());
        PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent("SMS_SENT"), 0);
        PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent("SMS_DELIVERED"), 0);
        int AddresseesPerMessage = 10;
        StringBuilder builder = new StringBuilder();
        String delim = "";
        for (ContactItem c:smsMessage.getAddresseeList()) {
            //  For every phone number in our list
            builder.append(delim).append(c.getPhoneNumber().toString());
            delim=";";
            if (((smsMessage.getAddresseeList().indexOf(c)+1) % AddresseesPerMessage) == 0 || smsMessage.getAddresseeList().indexOf(c)+1 == smsMessage.getAddresseeList().size()) {
                // using +1 because index 0 mod 9 == 0 
                for(String text : smsMessageText){
                    //  Send 160 bytes of the total message until all parts are sent
                    smsMgr.sendTextMessage(builder.toString(), null, text, sentPI, deliveredPI);
                }
                builder.setLength(0);
                delim="";
            }
        }
    }

use this code...i hope its useful to you.

dipali
  • 10,966
  • 5
  • 25
  • 51