I want to share images from MIUI gallery app to my app but received intent has data=null
and
uri=content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FAndroid%2Fdata%2Fcom.miui.gallery%2Fcache%2FSecurityShare%2F1657350098978.jpg
Then i use Cursor
to get file path and path is:
/storage/emulated/0/Android/data/com.miui.gallery/cache/SecurityShare/1657350098978.jpg
As you see, it shares from its data folder, So my app can not reach the file. This is happening only for images and only in Xiomi MIUI gallery app.
This is my manifest:
<activity
android:name=".activity.ReceiveShareActivity"
android:configChanges="uiMode"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
And this is my code:
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
final String[] columns = {MediaStore.Files.FileColumns.DATA,
MediaStore.Files.FileColumns.DISPLAY_NAME,
MediaStore.Files.FileColumns.SIZE,
MediaStore.Files.FileColumns._ID};
final String orderBy = MediaStore.Files.FileColumns._ID;
Cursor cursor = getContentResolver().query(uri, columns, MediaStore.Files.FileColumns.SIZE + ">0", null, orderBy);
Thanks to @blackapps, I tried with Inputstream
with URI and it works well.