earthview-android icon indicating copy to clipboard operation
earthview-android copied to clipboard

Android M permissions

Open enricocid opened this issue 8 years ago • 1 comments

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:)

enricocid avatar Feb 14 '16 10:02 enricocid

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.

PDDStudio avatar Feb 14 '16 12:02 PDDStudio