如何在Android M中按单个请求检查多个权限? [英] How to check the multiple permission at single request in Android M?

查看:270
本文介绍了如何在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.

这篇关于如何在Android M中按单个请求检查多个权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆