How do I send sms to multiple phone numbers in android
using sms manager it does not work with a csv list; is there any way besides looping and sending more than one text to send to multiple recipients?
or is 开发者_如何学Pythonthis by design a non-spam feature?
Intent smsIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:5551212;5551212"));
smsIntent.putExtra("sms_body", "sms message goes here");
startActivity(smsIntent);
Add a semicolon delimited list of phone numbers to "smsto:" as the URI in the Intent constructor.
In SAMSUNG devices You have to separate the phone numbers with ',' while other devices are accept the ';'.So your code should be like that:-
String separator = "; ";
if(android.os.Build.MANUFACTURER.equalsIgnoreCase("samsung")){
separator = ", ";
}
try {
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("address", "55555"+seperator+"66666");
sendIntent.putExtra("sms_body", "Here is My text");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
精彩评论