gpt4 book ai didi

Android - 更改 READ_PHONE_STATE 权限请求消息

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:53:41 24 4
gpt4 key购买 nike

我正在使用 Android Marshmallow READ_PHONE_STATE 权限,我想更改显示在权限请求中的文本。

默认显示:

Allow [App name] to make and manage phone calls?

但我正在使用它来获取设备 IDsim 序列号,所以我认为最好更改请求消息。有谁知道怎么做(一些特殊功能或什么的)?

或者我只需要为此实现一个独立的Dialog

非常感谢。

最佳答案

不,您不能更改对话框中的文本。它在系统中默认实现。在请求许可之前,您可以提供有关许可的简要说明。这样用户就会确切地知道您将使用它做什么。

Request Permissions

If your app needs a dangerous permission that was listed in the app manifest, it must ask the user to grant the permission. Android provides several methods you can use to request a permission. Calling these methods brings up a standard Android dialog, which you cannot customize.

Explain why the app needs permissions

In some circumstances, you might want to help the user understand why your app needs a permission. For example, if a user launches a photography app, the user probably won't be surprised that the app asks for permission to use the camera, but the user might not understand why the app wants access to the user's location or contacts. Before you request a permission, you should consider providing an explanation to the user. Keep in mind that you don't want to overwhelm the user with explanations; if you provide too many explanations, the user might find the app frustrating and remove it.

One approach you might use is to provide an explanation only if the user has already turned down that permission request. If a user keeps trying to use functionality that requires a permission, but keeps turning down the permission request, that probably shows that the user doesn't understand why the app needs the permission to provide that functionality. In a situation like that, it's probably a good idea to show an explanation.

To help find situations where the user might need an explanation, Android provides a utiltity method, shouldShowRequestPermissionRationale(). This method returns true if the app has requested this permission previously and the user denied the request.

documentation 中有更多详细信息

关于Android - 更改 READ_PHONE_STATE 权限请求消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37273033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com