In my Android Aplication I just need to open SMS intent with pre populated message_body and the PhoneNumber.
Following is the code I am trying
Uri uri = Uri.parse(String.format("smsto:%s", strPhoneNumber));
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, uri);
smsIntent.putExtra("sms_body", "Sample Body");
startActivityForResult(smsIntent, OPEN_SMS_APP);
All works great in default scenario but if Facebook Messenger is installed and setup it as the default SMS Application (settings -> Apps & Notifications -> Default Apps -> SMS app) then the functionality breaks.
Problem is, it opens FB messenger without the message_body (empty) even though it correctly picks the phone number (in FB Messenger APP).
Further, I tried following tests but didn't pick SMS_BODY or opened default Android APP
smsIntent.addCategory(Intent.CATEGORY_APP_MESSAGING); // STILL DIDN'T FIX
smsIntent.putExtra(Intent.EXTRA_TEXT, "Sample Body"); // STILL DIDN'T FIX
Questions
- Is there a way that I can force to open default Android SMS Application (Messages APP) even if someone have setup any other 3rd party SMS application as default App?
- OR Any other way I can pass message_body parameter to work in other 3rd party applications as well?
new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", number, null))
only and do not addIntent.CATEGORY_APP_MESSAGING
. I think URIsms
should not pick fbmessanger app . Or am i missing something here? – Samaveda