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

查看:33
本文介绍了如何在 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);

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

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天全站免登陆