I have an activity which accepts android.intent.action.SEND
.
It accepts some media files and texts.
As it accepts a new 'share' it does some validation checks and pass the Uri to a service, it looks like this:
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
Intent serviceIntent = new Intent(this, ShareService.class)
.setData(uri)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) // probably redundant but harmless here
.putParcelableArrayListExtra(Constants.EXTRA_SHARE_FILES, uris)
startService(serviceIntent);
It works for all file
providers and usually for content
as well, but from time to time I get reports of failures:
Non-fatal Exception: java.lang.SecurityException: UID 10283 does not have permission to content://com.whatsapp.provider.media/item/33560 [user 0]
Is there anything I can do to keep the Uri permission alive? how should I handle this kind of Uri?