Whenever we share a media file with our app, that file we should have access to display, but in the Xioami device we are unable to access those files, whereas for other device like vivo, oppo, realme, oneplus etc. is working fine and able to display or read those file.
For android 10 version it's working fine in redmi device but for android 11 (SDK 30) it's not working.
Even popular app like Whatsapp, facebook, Instagram, Telegram and Singal also unable to attach file from out side the application.
Can anyone please give your feedback and help how we can fix this problem in future.
Below is my code to get media uri
String action = getIntent().getAction();
String type = getIntent().getType();
if (Intent.ACTION_SEND.equals(action) {
if (type.equals("text/plain")) {
String textMessage = getIntent().getStringExtra(Intent.EXTRA_TEXT);
} else if(type.startsWith("image/")) {
Uri imageUri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
String path = imageUri.getPath();
} else if(type.startsWith("video/")) {
Uri videoUri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
String path = videoUri.getPath();
}
}
We also have used custom parser to get file path from uri but didn't work.
File provider also included in xml directory.