I am trying to send multiple images with com.android.mms via intents, but it crashes.
The mms works correctly when I send a single image using ACTION_SEND.
Does any one have some insights as to why this is the case? ACTION_SEND_MULTIPLE should be a valid action for mms because the mms app is displayed in the chooser dialog (Messages icons in the image below).
I use the following codes to open a chooser dialog.
public static void openDialog(Context context,
String title,
String snippet,
Set<String> fileUrls) {
if (fileUrls != null && !fileUrls.isEmpty()) {
String shareText =
prepareShareText(context, snippet);
ArrayList<Uri> files = new ArrayList<Uri>();
for (String path : fileUrls) {
File file = new File(path);
Uri uri = FileProvider.getUriForFile(context,
context.getString(R.string.file_provider_authority),
file);
files.add(uri);
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TEXT, shareText);
intent.setType("image/*");
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
context.startActivity(Intent.createChooser(intent, "Share media"));
}
}
When I select "Messages" (com.android.mms), the mms app tries to open but crashes with the following errors
E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15195)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2492)
at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:688)
at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
at android.os.Binder.execTransact(Binder.java:404)
at dalvik.system.NativeStart.run(Native Method)
W/ActivityManager: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
W/ActivityManager: mDVFSHelper.acquire()
W/ResourceType: Failure getting entry for 0x01080a7f (t=7 e=2687) in package 0 (error -75)
W/Settings: Setting window_animation_scale has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
E/Qdio::ParseQdio: File Open Error
E/Qdio::ParseQdio: File Open Error
E/CursorWindow: Failed to read row 0, column 0 from a CursorWindow which has 1 rows, 0 columns.
W/dalvikvm: threadid=14: thread exiting with uncaught exception (group=0x41e93da0)
E/AndroidRuntime: FATAL EXCEPTION: addAttachment
Process: com.android.mms, PID: 13192
java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetString(Native Method)
at android.database.CursorWindow.getString(CursorWindow.java:439)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
at android.database.CursorWrapper.getString(CursorWrapper.java:114)
at com.android.mms.ui.MessageUtils.getMimeTypeFromUri(MessageUtils.java:6323)
at com.android.mms.util.HandleComposerAttachment$32.run(HandleComposerAttachment.java:2476)
at java.lang.Thread.run(Thread.java:841)
W/ActivityManager: Force finishing activity com.android.mms/.ui.ComposeMessageMms
Edit:
Do note that the error log is from the com.android.mms app itself (not from my app). I selected "no filters" on the logcat to see them.
the permission denial error also appears when I send a single image, but it does not cause a "FATAL EXCEPTION: addAttachment" crash.