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

Handling Scope Storage for Android 11 and above #26

Open
100CPU opened this issue Jan 18, 2022 · 3 comments
Open

Handling Scope Storage for Android 11 and above #26

100CPU opened this issue Jan 18, 2022 · 3 comments
Labels

Comments

@100CPU
Copy link

100CPU commented Jan 18, 2022

Will this lib be further developed so that it also works with Android 11, where the authorization concept is completely different?

Will this lib be further developed so that it also works with Android 11, where the authorization concept is completely different?
I also use this lib, but the permissions don't work on smartphones with Android 11 and higher.

@tajchert
Copy link
Owner

tajchert commented Jan 18, 2022

Hi, PR with updates are welcomed and highly encouraged.
I didn't test this library for all cases on Android 11

Also can you specify what is not working in more details?

@100CPU
Copy link
Author

100CPU commented Jan 19, 2022

We use the following method of your lib. That works/worked until Android 10. From Android 11, as mentioned, has a different concept of accessing/writing files. Therefore the app cannot access to /storage/emulated/0/ to make there an directory and under there a zip-file like /storage/emulated/0/myDir/file.zip.
Error message "Permission denied". On other devices with Android < 11, it works!

It would be great if the library would be expanded accordingly so that it corresponds to Android's authorization concept.

public static Boolean askForReadPermission(final Activity activity, final PermissionCallback permissionCallback, View view){

 if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Nammu.checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)){
            return true;
        }
        else{
            final String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};

            if (Nammu.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)){
                Snackbar.make(view, activity.getString(R.string.error_permission_backup),
                        Snackbar.LENGTH_INDEFINITE)
                        .setAction("OK", new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                Nammu.askForPermission(activity, permissions, permissionCallback);
                            }
                        }).show();
            } else {
                Nammu.askForPermission(activity, permissions, permissionCallback);
            }
            return false;
        }
    }

@tajchert
Copy link
Owner

I believe with Scope Storage it is up to app developer to pick either a particular file from external storage or ask for "All file access" (however it shouldn't be assumed as default behavior as a replacement for WRITE_EXTERNAL_STORAGE ).

I tried this on Android 13 and seems to be working as intended in existing functionality (it returns "permission refused").
If you believe this should be part of this library for every app - please provide a PR with a change.

@tajchert tajchert changed the title Further development planned for Android 11? Handling Scope Storage for Android 11 and above Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants