如何在 Android 中自定义权限对话框? [英] How can I customize permission dialog in Android?

查看:70
本文介绍了如何在 Android 中自定义权限对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在运行时请求一个权限,如下所示:

Suppose I request a permission at runtime like the following:

ActivityCompat.requestPermissions(thisActivity,
            new String[]{Manifest.permission.READ_CONTACTS},
            MY_PERMISSIONS_REQUEST_READ_CONTACTS);

Android 系统会创建一个弹出对话框来请求权限.如何为该对话框定义自定义布局?

Android system creates a popup dialog to request permission. How can I define a custom layout for that dialog?

推荐答案

简短的回答是,你不能.

正如 android 文档所说:

As android documentation puts:

当您的应用调用 requestPermissions() 时,系统会向用户显示一个标准对话框.您的应用无法配置或更改该对话框.如果您需要向用户提供任何信息或解释,则应在调用 requestPermissions() 之前执行此操作,如解释应用为何需要权限"中所述.

When your app calls requestPermissions(), the system shows a standard dialog box to the user. Your app cannot configure or alter that dialog box. If you need to provide any information or explanation to the user, you should do that before you call requestPermissions(), as described in "Explain why the app needs permissions".

因此,目前无法为权限对话框定义自定义布局.

So, there is no way to define a custom layout for the permission dialog for now.

您可以在此处找到更多详细信息:http://developer.android.com/training/permissions/requesting.html

You can find more detailed information here: http://developer.android.com/training/permissions/requesting.html

这篇关于如何在 Android 中自定义权限对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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