Android 6.0 multiple permissions

Just include all 4 permissions in the ActivityCompat.requestPermissions(…) call and Android will automatically page them together like you mentioned. I have a helper method to check multiple permissions and see if any of them are not granted. public static boolean hasPermissions(Context context, String… permissions) { if (context != null && permissions != null) { for … Read more

How do I use sudo to redirect output to a location I don’t have permission to write to? [closed]

Your command does not work because the redirection is performed by your shell which does not have the permission to write to /root/test.out. The redirection of the output is not performed by sudo. There are multiple solutions: Run a shell with sudo and give the command to it by using the -c option: sudo sh … Read more

Storage permission error in Marshmallow

You should be checking if the user has granted permission of external storage by using: if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Log.v(TAG,”Permission is granted”); //File write logic here return true; } If not, you need to ask the user to grant your app a permission: ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_CODE); Of course these are for marshmallow devices … Read more

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); } } } … Read more