It seems that data exchange with other applications on Android M is possible only when another application manually requested READ_EXTERNAL_STORAGE permission, and I'm wondering if anyone knows about this without manually opening all the applications for which I can share and choose Permission to storage.
For example, I have the following Intent for sharing some data:
Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Some Image Subject"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(someFile)); startActivity(Intent.createChooser(shareIntent, "Share via..."));
Suppose that someFile exists, and that I have already implemented the recommended runtime resolution model proposed in http://developer.android.com/training/permissions/requesting.html , and the user agreed to allow my permission, so the file is actually created in the system .
Is there a way to let me know that I am using an application to which I have granted this permission to my user, can you provide this on my behalf?
This does not work:
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
According to the documentation:
int FLAG_GRANT_READ_URI_PERMISSION
If set, the recipient of this intent will be granted permission to perform read operations on the URI in the Intent data and any URIs specified in its ClipData.
And even more interestingly, if this flag is set and I share with Gmail, the flag is not detected, and Google does not request permission, but simply catches the exception and does not attach my file.
Any help would be appreciated.