Skip to content Skip to sidebar Skip to footer

Storage Permission Issue For My Wallpaper App In Android Marshmallow

Even after adding storage permission to my app I am unable to set wallpaper or download wallpaper (one function of my app) Its like wallpaper setting app. and unable to share the w

Solution 1:

public boolean ifPermissionReady(){

        if (ContextCompat.checkSelfPermission(getActivity(),
                Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
            System.out.println("req write storage permission*****");
            checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Constant.PERMISSION_WRITE_EXTERNAL_STORAGE);
            return false;
        }
        return true;
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        System.out.println("onRequestPermissionsResult******");

        //onStateNotSaved();
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        switch (requestCode) {

            case Constant.PERMISSION_WRITE_EXTERNAL_STORAGE:{
                if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    //Do something
                } else {
                    System.out.println("---> permission denied");
                    //Do something
                }
            }

        }
    }

marshmallow require developer to acquire permission during runtime. Try above code.


Post a Comment for "Storage Permission Issue For My Wallpaper App In Android Marshmallow"