我试图通过意图发送带有com.android.mms的多个图像,但它崩溃了。
使用ACTION_SEND发送单个图像时,mms可以正常工作。
对于为什么会这样,有没有人有一些见解? ACTION_SEND_MULTIPLE应该是mms的有效操作,因为mms应用程序显示在选择器对话框中(下图中的消息图标)。
我使用以下代码打开选择器对话框。
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"));
}
}
当我选择&#34;消息&#34; (com.android.mms),mms应用程序尝试打开但崩溃时出现以下错误
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
修改:
请注意,错误日志来自com.android.mms应用程序本身(而不是来自我的应用程序)。我选择了#34;没有过滤器&#34;在logcat上看到它们。
当我发送单个图像时,也会出现权限拒绝错误,但它不会导致&#34; FATAL EXCEPTION:addAttachment&#34;崩溃。