Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library doesn't showing types other than images on Android 11 (like pdf, doc) #125

Open
Bharatsingh-nickelfox opened this issue Feb 16, 2021 · 2 comments

Comments

@Bharatsingh-nickelfox
Copy link

No description provided.

@Bharatsingh-nickelfox Bharatsingh-nickelfox changed the title Library doesn't showing types other than images on Android 11 Library doesn't showing types other than images on Android 11 (like pdf, doc) Feb 16, 2021
@pradeep-orbi
Copy link

Did you find any solution for this problem ? I want to filter and show only pdfs. I tried another library, but that also has some issues.

@MuhammadSulaiman001
Copy link

MuhammadSulaiman001 commented Sep 14, 2021

Hi there, The library was working properly before upgrading to android R (API 30)... Now it does see nothing but the images.
I have found a solution for this. You have to add this permission check somewhere in your code:

if (isAndroid11ReadFilesPermissionRequired())
                askForAndroid11ReadFilesPermission()

where

private fun isAndroid11ReadFilesPermissionRequired() =
        SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()

@RequiresApi(Build.VERSION_CODES.R)
private fun askForAndroid11ReadFilesPermission() {
    try {
        val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
        intent.addCategory("android.intent.category.DEFAULT");
        intent.data =
            Uri.parse(String.format("package:%s", getApplicationContext().packageName));
        startActivityForResult(intent, FILE_PICKER_ANDROID11_REQUEST_CODE);
    } catch (e: Exception) {
        myTimber(e)
        val intent = Intent()
        intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
        startActivityForResult(intent, FILE_PICKER_ANDROID11_REQUEST_CODE)
    }
}

Also, I have added this to AndroidManefist.xml:

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
    tools:ignore="ScopedStorage" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants