这是我在Mi手机上尝试上传图片时遇到的错误。但对于其他手机,它工作正常。
java.lang.RuntimeException: Failure delivering result
ResultInfo{who=null, request=1, result=-1, data=Intent { flg=0x1 clip={image/* text/uri-list U:content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20171107_230239.jpg} (has extras) }} to activity {com.fullstacknet.chatapp/com.fullstacknet.chatapp.ChatActivity}:
java.lang.IllegalArgumentException: Invalid URI: content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20171107_230239.jpg
at android.app.ActivityThread.deliverResults(ActivityThread.java:4108)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4151)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1551)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6195)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
Caused by: java.lang.IllegalArgumentException: Invalid URI: content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20171107_230239.jpg
at android.provider.DocumentsContract.getDocumentId(DocumentsContract.java:917)
at com.fullstacknet.chatapp.ChatActivity.getRealPathFromURI(ChatActivity.java:896)
at com.fullstacknet.chatapp.ChatActivity.onActivityResult(ChatActivity.java:962)
at android.app.Activity.dispatchActivityResult(Activity.java:6998)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4104)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4151)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1551)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6195)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
11-08 13:38:59.261 28831-28831/com.fullstacknet.chatapp E/MQSEventManagerDelegate: failed to get MQSService.
我正在使用以下意图选择图片:
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), 1);
在选择完图片后,它没有进入onActivityResult
。你有什么解决问题的想法吗?