When file is shared by other apps via FileProvider then the Uri received in my app is not readable. If i try to get file path or create file from it then it says file doesn't exist. The sample Uri is from whatsapp is content://com.whatsapp.provider.media/item/91836 . It gives Security exception when i try to read bitmap from the Uri.
Code lines is onCreate method:
Uri mediaUri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mediaUri);
Manifest:
<activity
android:name=".ui.main.MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustNothing">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/mp4" />
<!--<data android:mimeType="video/*" />-->
</intent-filter>
</activity>
Exception:
Caused by: java.lang.SecurityException: Permission Denial: opening provider com.whatsapp.MediaProvider from ProcessRecord{fbda37f 23891:com.fayvo/u0a273} (pid=23891, uid=10273) that is not exported from UID 10133
at android.os.Parcel.createException(Parcel.java:1953)
at android.os.Parcel.readException(Parcel.java:1921)
at android.os.Parcel.readException(Parcel.java:1871)
at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:4159)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:6759)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2912)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1879)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1460)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1313)
at android.content.ContentResolver.openInputStream(ContentResolver.java:1033)
at android.provider.MediaStore$Images$Media.getBitmap(MediaStore.java:919)