I am maintaining an app which allows you to share via SMS with the following code:
String separator = "; ";
if(android.os.Build.MANUFACTURER.toLowerCase().contains("samsung")){
separator = ", ";
}
StringBuilder uri = new StringBuilder("sms:");
for (int i = 0; i < nums.length; i++) {
uri.append(nums[i]);
if( i < (nums.length -1) )
uri.append(separator);
}
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.setData(Uri.parse(uri.toString()));
smsIntent.putExtra("sms_body", smsBody);
startActivityForResult(smsIntent, SMS_SENT_RESULT);
I have noticed the following bizarre behavior (occurs on a Samsung Galaxy S3 and a Kyocera Event, so - I think - not vendor specific):
When one of the phone numbers in nums contains the pound sign ('#'), all numbers after it are dropped. That is, if I try to send a message to 'Andy' at 1-111-111-1111, 'AT&T tech support' at *228#, and 'Betty' at 1-222-222-2222, the constructed URI is "sms:1-111-111-1111; *228#; 1-222-222-2222" but the resulting SMS has only "To: Andy, AT&T tech support".
Is there a workaround for this? Some alternative way of specifying the recipients, maybe, or an accepted style of escaping for Android intent URIs?