Runtime Error:(53, 45) error: cannot find symbol method checkSelfPermission(RuntimePermissionsActivity,String)

In your activity’s onCreate(), do the processing within the if block: (you are getting the error because you may be asking for permissions with simultaneous processing in the onCreate()):

    askForPermissions();
    if(checkForPermission()){
        //Do your processing here
    }

The functions are:

void askForPermissions(){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
            requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
        }
    }
}

boolean checkForPermission(){
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
}

Browse More Popular Posts

Leave a Comment