Thread
#compose
    Mehdi Haghgoo

    Mehdi Haghgoo

    1 year ago
    Does Jetpack Compose have easy integration with gallery and storage access for picking files?
    i

    Ian Lake

    1 year ago
    It will in the upcoming Activity Compose 1.3.0-alpha03: https://issuetracker.google.com/issues/172690553
    Mehdi Haghgoo

    Mehdi Haghgoo

    1 year ago
    So, it's not currently possible to access files from Compose. Is it?
    z

    zsperske

    1 year ago
    you can probably use
    AmbientContext
    in some way to do what you want
    Adam Powell

    Adam Powell

    1 year ago
    anything possible from any other part of the android sdk is possible from compose, and we wouldn't do anything in a future stock implementation of a file picker that you can't do yourself from the public api available today. 🙂
    i

    Ian Lake

    1 year ago
    You can certainly copy/paste the CL in that issue into your app
    Samir Basnet

    Samir Basnet

    1 year ago
    Does that mean we will be able to pick files/image without requiring that FileUtils class we generally use with methods to obtain filepath for different android versions containing lots of logic?
    i

    Ian Lake

    1 year ago
    That's absolutely never something you need to do on any API level. You should always be using
    ContentResolver
    APIs to open an input stream from the returning URI
    Samir Basnet

    Samir Basnet

    1 year ago
    But i have searched a lot and only found gists that handle it differently for different android versions. Can you provide a link to a proper guide or tutorial please?
    i

    Ian Lake

    1 year ago
    contentResolver.openInputStream(uri)
    is all you need to do to open any URI on any API. That's literally it
    Samir Basnet

    Samir Basnet

    1 year ago
    Thank you for the reply. Appreciate answering by noob question
    @Ian Lake Ok so it`s throwing error in case when my Uri is like this content://com.android.providers.media.documents/document/image%3A28 . How to handle such Uri ?
    i

    Ian Lake

    1 year ago
    Are you doing something other than calling
    contentResolver.openInputStream(thatExactUri)
    upon receiving that URI?
    Samir Basnet

    Samir Basnet

    1 year ago
    @Ian Lake Nope nothing after getting Uri thats the first thing i am doing
    <http://java.io|java.io>.FileNotFoundException: No such file or directory
    at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146)
    at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:691)
    at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1080)
    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:921)
    at android.content.ContentResolver.openInputStream