Skip to content Skip to sidebar Skip to footer

Android4.4 Can Not Handle Sms Intent With "vnd.android-dir/mms-sms"

My application has a button to start default sms activity and it worked perfectly fine all android version except new one, Android 4.4(kitkat) Here is the code: public void onClick

Solution 1:

To start the SMS app with number populated use action ACTION_SENDTO:

Intentintent=newIntent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:" + Uri.encode(phoneNumber)));
startActivity(intent);

This will work on Android 4.4. It should also work on earlier versions of Android however as the APIs were never public the behavior might vary. If you didn't have issues with your prior method I would probably just stick to that pre-4.4 and use ACTION_SENDTO for 4.4+.

Solution 2:

to start the sms app without insert the number, you should delete setType

Intentintent=newIntent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
intent.putExtra("sms_body", "smsMsgVar");
startActivity(intent);

Solution 3:

The issue happened when you are testing with Emulator,

Please test with the actual device.

Solution 4:

In Kotlin this code works:

valdefaultSmsPackageName= Telephony.Sms.getDefaultSmsPackage(activity)  
            valsendIntent= Intent(Intent.ACTION_SEND)
            sendIntent.type = "text/plain"
            sendIntent.putExtra("address", "sms:"+contactNumber)
            sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_msg_body))
            Timber.e("defaultSmsPackageName: "+defaultSmsPackageName)
            if (defaultSmsPackageName != null){ //Can be null in case that there is no default, then the user would be able to choose any app that support this intent.
                sendIntent.setPackage(defaultSmsPackageName)
                activity!!.startActivity(sendIntent)
            }

Post a Comment for "Android4.4 Can Not Handle Sms Intent With "vnd.android-dir/mms-sms""