Google+ Photos ACTION_VIEW, FLAG_GRANT_PERSISTABLE_URI_PERMISSION Exception

In my application, I have internal files that I would like to open in external viewers depending on the type of file. I have a FileProvider, as shown in the application manifest:

<provider
    android:name="android.support.v4.content.FileProvider"           
    android:authorities="com.myapp.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/paths" />
</provider>

To view the file, I can use the following code to show the application selector.

Uri contentUri = getUriForFile(getApplicationContext(), "com.myapp.fileprovider", thisFile);

Intent viewIntent = new Intent(Intent.ACTION_VIEW);
String mimeType = getApplicationContext().getContentResolver().getType(contentUri);

viewIntent.setDataAndType(contentUri, mimeType);
viewIntent.setFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);

try {
    startActivity(viewIntent);
} catch(ActivityNotFoundException e) {}

This works well for most applications, however, if I select the Google+ Photos app in the list while the image is uploaded to Google+ Photos, it will work right away if I try to enlarge the image until my fingers click it. It looks like Google+ Photos has lost access to the file, and when he tries to read it, he will be denied access.

All other apps I tried work fine Any suggestions rated

+4

All Articles