2

我正在尝试通过意图发送多个带有 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"));
    }
}

在此处输入图像描述

当我选择“消息”(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 应用程序本身(不是来自我的应用程序)。我在 logcat 上选择了“无过滤器”来查看它们。

当我发送单个图像时也会出现权限拒绝错误,但它不会导致“致命异常:addAttachment”崩溃。

4

0 回答 0