Image upload not working only in Mi mobiles

Viewed 1606

This is the error i am getting when i am trying to upload the image from Mi mobile.But for other phones it working fine

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.

I'm selecting the image using this Intent:

 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);

It is not hitting the onActivityResult after selecting the image. Any ideas on how I can resolve this issue?

3 Answers

that`s the solution , the key word ws

   private boolean corp(Activity activity, Uri uri, boolean fromCamera) {
        Intent cropIntent = new Intent("com.android.camera.action.CROP");
        if (fromCamera){
            cropIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
       ...

https://blog.csdn.net/weixin_40087231/article/details/89467708

The perfect solution is, Add below entities in your manifest file

android:hardwareAccelerated="false"

android:largeHeap="true"
Related