4

In my app I have internal files that I would like to be able to open in external viewers depending on file type. I have a FileProvider set up like the following 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>

I user the following code to show an application selector in order to view the file.

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 apps, however if I chose Google+ Photos app in the list, while the image will load fine in the Google+ Photos, it will crash immediately if I try too zoom in to the image by pinching with my fingers. It seem like Google+ Photos lost access to the file and when it tries to read it again it gets denied access.

All other apps I tried works perfectly Any suggestions appreciated

DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
www.jensolsson.se
  • 3,023
  • 2
  • 35
  • 65
  • If you figure that out please share your solution. I would reaaaaaaly appreciate that :). – molu2008 Dec 12 '14 at 15:24
  • 1
    I am facing the same problem with FileProvider and Photos/Google+ app. I found out that it is getting exception `java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow.`. Other apps just work fine so I would say it is problem of the Photos app. Unfortunately I did not found any solution so at least I sent crash reports to Google. :-) – Berťák Feb 03 '15 at 10:28
  • 1
    seeing same problem here - anyone found a solution yet? – vkislicins May 13 '15 at 09:43

0 Answers0