2

Hi i am updating my application jaffna Temples . so that it can support Android M devices (v 6.0 and above).

Is there a way i can request multiple permission at a single time. eg: I want to get the permission to read phone state and location information at the same time.

Using this ways i can request permission one by one. But i want to rest both permission at once at the start of the application.

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (checkSelfPermission(Manifest.permission.READ_PHONE_STATE)
                != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE},
                    PERMISSIONS_REQUEST_READ_PHONE_STATE);
        } else {
            setPhoneDetails();
        }
    }

Please give me some suggestions. Tnx.

Sathya Baman
  • 3,424
  • 7
  • 44
  • 77

1 Answers1

2

Is there a way i can request multiple permission at a single time

Put more than one permission in the String[] that you are passing to requestPermissions().

For example, in this sample project, I define collections of permissions statically, such as:

  private static final String[] PERMS_TAKE_PICTURE={
    CAMERA,
    WRITE_EXTERNAL_STORAGE
  };

so that I can request those permissions later:

ActivityCompat.requestPermissions(this, PERMS_TAKE_PICTURE,
    RESULT_PERMS_INITIAL);
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491