How do I show permissions rationale for multiple permissions request?

做~自己de王妃 提交于 2019-12-23 03:25:09

问题


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

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

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

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?


回答1:


I recommend this open source.

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


来源:https://stackoverflow.com/questions/42009948/how-do-i-show-permissions-rationale-for-multiple-permissions-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!