如何在Android M中按单个请求检查多个权限?

问题描述:

我要使用

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

在单个请求中使用

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

但是我的问题是,我当时只请求一个许可, 我读过有关组权限的信息,但它仅适用于开发人员决定的同一组,例如CONTACT_GROUP : read_contact,write_contact等.

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.

谢谢

您可以在单个请求中请求(来自不同组的)多个权限.为此,您需要将所有权限添加到作为您的requestPermissions API的第一个参数提供的字符串数组中,如下所示:

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);

执行此操作时,您将看到权限弹出窗口,它是多个权限弹出窗口的堆栈.当然,您需要处理每个权限的接受和拒绝(包括不再询问")选项.在此处 a>.

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.