Skip to content Skip to sidebar Skip to footer

Why Doesn't This Code Attach An Image To Mms Message?

The code is pretty basic share_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Uri image = Uri.parse('android.re

Solution 1:

The intent is transfered to an external application.

The android:resource scheme is only valid locally.

That means that you have to copy the image from your resources to an external directory and link this new file in your Intent

Solution 2:

How about using the FLAG_GRANT_READ_URI_PERMISSION flag from the Intent class : http://developer.android.com/reference/android/content/Intent.html#FLAG_GRANT_READ_URI_PERMISSION

As the name says, this should transfer Read permission on the given Uri to the activity started by that intent.

Solution 3:

What does your Uri.parse() return? Null maybe?

Try this:

Resourcesresources= context.getResources(); 
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + 
resources.getResourcePackageName(imageToSend) + '/' + 
resources.getResourceTypeName(imageToSend) + '/' + 
resources.getResourceEntryName(imageToSend) ); 

Post a Comment for "Why Doesn't This Code Attach An Image To Mms Message?"