How to check the multiple permission at single request in Android M?

Zala Janaksinh picture Zala Janaksinh · Dec 2, 2015 · Viewed 110.7k times · Source

I want to use the

  1. android.permission.CAMERA
  2. android.permission.WRITE_EXTERNAL_STORAGE

in single request using

ActivityCompat.requestPermissions(Activity activity,new String permisionList[],int permissionRequestcode);

But my problem is at time I request only one permission, I read about group-permission,But it's work for only Same group which one decided by Developer, Like CONTACT_GROUP : read_contact,write_contact etc.

I want create the custom group permission which ask me only one request & provide me only one response.

Thanks

Answer

Uncaught Exception picture Uncaught Exception · Mar 17, 2016

You can ask multiple permissions (from different groups) in a single request. For that, you need to add all the permissions to the string array that you supply as the first parameter to the requestPermissions API like this:

requestPermissions(new String[]{
                                Manifest.permission.READ_CONTACTS,
                                Manifest.permission.ACCESS_FINE_LOCATION},
                        ASK_MULTIPLE_PERMISSION_REQUEST_CODE);

On doing this, you will see the permission popup as a stack of multiple permission popups. Ofcourse you need to handle the acceptance and rejection (including the "Never Ask Again") options of each permissions. The same has been beautifully explained over here.