Frank Frank - 4 months ago 95
Android Question

Android 6.0 multiple permissions

I know that Android 6.0 has new permissions and I know I can call them with something like this

if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) !=
new String[] {

Today I saw a Google app which needs 3 permissions: contacts, sms and camera. It's making a page 1-3 and calls them all together at the same time to activate.

Can anybody tell me how I can call 4 permissions to activate at the same time like sms, camera, contacts and storage?

Example (forgot the name of the google app :( )

The app needs sms,contacts and camera

the app asked me (and made a dialog page1-3) activate sms, activate contacts and then camera.
So this google app was calling all 3 required permissions together and my question is how can i achive the same ?


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 (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context != null && permissions != null) {
        for (String permission : permissions) {
            if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                return false;
    return true;

Then just send it all of the permissions. Android will ask only for the ones it needs.

// The request code used in ActivityCompat.requestPermissions()
// and returned in the Activity's onRequestPermissionsResult()
String[] PERMISSIONS = {Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_SMS, Manifest.permission.CAMERA};

if(!hasPermissions(this, PERMISSIONS)){
    ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);