Srikanth Pai
Srikanth Pai

Reputation: 926

How to show the dialog of all the messaging options in android?

enter image description hereI am trying to send text messages to the selected contacts on the phone using the SmsManager but by default it sends the message using the phone GSM message option. My requirement is to show the popup to the user to choose is messaging options such as WHATSAPP, VIBER etc as shown in the image

here is my code

SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage("9844598445", null, "Hello There", null, null);

Please help

Upvotes: 1

Views: 390

Answers (2)

Jithu P.S
Jithu P.S

Reputation: 1843

Try this one

Uri uri = Uri.parse("smsto:" + smsNumber);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", smsText);  
startActivity(intent);

Upvotes: 3

Raghav Sood
Raghav Sood

Reputation: 82563

What you're doing right now is directly send an SMS through the SDK. If you want to offer the user the option to send it through another installed app, you need to use an Intent:

Uri uri = Uri.parse("smsto:1234567890");   
Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
it.putExtra("sms_body", "The SMS text");   
startActivity(it);  

Upvotes: 1

Related Questions