如何显示多个权限请求的权限原理

如何显示多个权限请求的权限原理

本文介绍了如何显示多个权限请求的权限原理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android API 25,并且需要在应用中提出权限请求.

I am working with Android API 25 and need to make permissions requests in the app.

关于如何发出请求以及如何说明基本原理,有大量的代码示例. 此处的链接显示了一种简单的方法,例如:, Android M请求权限非活动

There are a ton of code samples on how to make a request as well as how to show the rationale. This link here shows a simple methodology as do these: Android M Request Multiple permission at a single time , Android M request permission non activity

我遇到的问题是我一次请求多个权限(位置,写入存储访问和联系人),而ActivityCompatApi23.shouldShowRequestPermissionRationale源代码仅将String用于单个权限,而不将数组用于多个权限. (来源:android.support.v4.app.ActivityCompat)

The problem I am having is I am requesting multiple permissions at once (Location, Write storage access, and Contacts) and the ActivityCompatApi23.shouldShowRequestPermissionRationale source code only takes in a String for a single permission and not an array for multiple permissions. (source: android.support.v4.app.ActivityCompat)

因此,在我的代码中,我可以这样做:

So in my code, I can do this:

     ActivityCompat.requestPermissions(activity, permissionsStringArray, 123);

并尝试一次请求多个,但如果它们从以下位置返回true,则无法显示所需的解释:

And try to request multiple at once, but I can't then show the explanation for the ones needed if they return true from:

     ActivityCompat.shouldShowRequestPermissionRationale(activity,
                    currentPerm.getPermissionManifestName()

有人对我如何显示一个包含多个基本原理而不是一个基本原理的对话框有任何建议吗?

Does anyone have any recommendations on how I can show a dialog that includes multiple rationales in it as opposed to one at a time?

推荐答案

我推荐此开源程序.

https://github.com/ParkSangGwon/TedPermission

您可以简单地使用.例如

You can use simply. for example

private void CheckPermission() {

        new TedPermission(this)
                .setPermissionListener(permissionlistener)
                .setDeniedMessage(getString(R.string.str_permission1))
                .setPermissions(Manifest.permission.CAMERA, android.Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .check();
    }

这篇关于如何显示多个权限请求的权限原理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 16:29