1

I have an app that needs access to the gallery of the user to let it choose an image and perform transformations on it. I'd like to port this feature to the instant app experience. I know that the READ_EXTERNAL_STORAGE permission is not available for instant apps but with an ACTION_GET_CONTENT or with new ActivityResultContracts.GetContent() we don't need it.

I'm able to open the gallery and to choose a picture but I got this error when I try to access it:

class j1.q: Failed to load resource
There were 3 causes:
    java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
    java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
    java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
        call GlideException#logRootCauses(String) for more detail
        Cause (1 of 4): class j1.q: Fetching data failed, class java.io.InputStream, LOCAL
    There was 1 cause:
    java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
        call GlideException#logRootCauses(String) for more detail
        Cause (1 of 1): class java.io.FileNotFoundException: No content provider: content://com.android.providers.media.documents/document/image%3A221
        Cause (2 of 4): class j1.q: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
    There was 1 cause:
    java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
        call GlideException#logRootCauses(String) for more detail
        Cause (1 of 1): class java.io.FileNotFoundException: No content provider: content://com.android.providers.media.documents/document/image%3A221
        Cause (3 of 4): class j1.q: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL
    There was 1 cause:
    java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
        call GlideException#logRootCauses(String) for more detail
        Cause (1 of 1): class java.io.FileNotFoundException: No content provider: content://com.android.providers.media.documents/document/image%3A221
        Cause (4 of 4): class j1.q: Failed LoadPath{HierarchicalUri->Bitmap->Bitmap}, LOCAL
        Cause (1 of 1): class j1.q: Failed DecodePath{HierarchicalUri->Bitmap->Bitmap}

I have seen this question from 4 years ago Not able to launch Gallery from Android Instant app

Now we are able to open the gallery so maybe there were some changes done on this topic from the google side.

Is anyone able to get a picture from the gallery on an instant app?

Julien
  • 11
  • 1

2 Answers2

2

READ/WRITE_EXTERNAL_STORAGE: Instant apps do not have access to external storage. https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle#non-supported-permissions

Jitesh V
  • 36
  • 7
0

As mentioned on Android docs for instant app :

READ/WRITE_EXTERNAL_STORAGE: Instant apps do not have access to external storage; use internal storage instead.

you have another option which is to use CameraX to take pictures directly in your app (user internal storage instead).

Mohammad
  • 177
  • 2
  • 9