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

Android M permissions #21

Open
enricocid opened this issue Feb 14, 2016 · 1 comment
Open

Android M permissions #21

enricocid opened this issue Feb 14, 2016 · 1 comment

Comments

@enricocid
Copy link

Why don't You ask for permissions on main activity? If one goes to the settings would not be able to change the 'Wallpaper export location' since permissions are asked only when downloading a wallpaper. I think it would be easier and it would require only few lines of code

private final static int READ_EXTERNAL_STORAGE_PERMISSION_REQUEST=1;

and onCreate

if (Build.VERSION.SDK_INT >= 23 && PermissionChecker.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PermissionChecker.PERMISSION_GRANTED) {
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_PERMISSION_REQUEST);
        }

You can also explain why you need permissions if You want

@Override
    public void onRequestPermissionsResult (int requestCode, String[] permissions, int[] grantResults) {
        if(requestCode==READ_EXTERNAL_STORAGE_PERMISSION_REQUEST && grantResults[0]!=PermissionChecker.PERMISSION_GRANTED) {
            Utils.showMessageDialog();
        }
    }

showing a simple dialog using material dialogs library:)

public void showMessageDialog() {
        new MaterialDialog.Builder(this)
                .title(R.string.permissions_title)
                .content(R.string.explain_why)
                .positiveText(android.R.string.ok)
                .negativeText(android.R.string.no)
                .show();
    }

just a hint :)
I don't have a working as, or I would have sent a pull request:)

@PDDStudio
Copy link
Owner

Thanks for pointing out, indeed you can only change the export location after granting storage permission (which appears when downloading a wallpaper. I'm going to have a look at this.

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

No branches or pull requests

2 participants