android - 为什么RECEIVE_SMS和READ_SMS权限没有不同的提示框要求权限?

标签 android android-permissions

我在我的应用程序的 list 文件中列出了 RECEIVE_SMS 和 READ_SMS 的权限,它们也有不同的权限字符串。

授予相应的权限。但是,我注意到在授予(由用户)任何一项权限(READ_SMSRECEIVE_SMS)时,我们可以执行这两项任务。我的问题是,如果他们都执行不同的任务:

1) READ_SMS:它允许应用读取用户手机上的所有短信(当前存在)。

2) RECEIVE_SMS:它允许应用程序收听用户在使用该应用程序时手机上收到的所有短信。

它们在请求权限和拒绝其中一个权限时都显示相同的对话框,这两个对话框都不会出现。

如果两者具有相同的权限授予场景,那么为什么它们以两种权限的形式分开?如果你们中的任何人都可以帮助我理解这一点,那将对我有很大的帮助。

最佳答案

根据 Android documentation on Requesting Permissions :

Permission groups:
All dangerous Android system permissions belong to permission groups. If the device is running Android 6.0 (API level 23) and the app's targetSdkVersion is 23 or higher, the following system behavior applies when your app requests a dangerous permission:

If an app requests a dangerous permission listed in its manifest, and the app does not currently have any permissions in the permission group, the system shows a dialog box to the user describing the permission group that the app wants access to. The dialog box does not describe the specific permission within that group. For example, if an app requests the READ_CONTACTS permission, the system dialog box just says the app needs access to the device's contacts. If the user grants approval, the system gives the app just the permission it requested.

If an app requests a dangerous permission listed in its manifest, and the app already has another dangerous permission in the same permission group, the system immediately grants the permission without any interaction with the user. For example, if an app had previously requested and been granted the READ_CONTACTS permission, and it then requests WRITE_CONTACTS, the system immediately grants that permission.

警告:Android SDK 的 future 版本可能会将特定权限从一个组移动到另一个组。因此,不要将您的应用程序逻辑基于这些权限组的结构。 例如,如果您的应用程序请求 READ_CONTACTS 权限,然后是 WRITE_CONTACTS 权限,您不应该假设系统可以自动授予 WRITE_CONTACTS 权限,即使它与 Android 8.0(API 级别 26)中的 READ_CONTACTS 在同一权限组中.

所有与短信相关的权限都属于权限组SMS .
以下是短信权限组下的权限列表:

  • 发送短信
  • 发送短信
  • RECEIVE_SMS
  • READ_SMS
  • RECEIVE_WAP_PUSH
  • RECEIVE_MMS

关于android - 为什么RECEIVE_SMS和READ_SMS权限没有不同的提示框要求权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48634766/

相关文章:

android - TabHost 开头不显示内容

android - 为什么 LiveLiteralsKt 会导致运行时问题?

安卓谷歌地图位置

android - 检查哪些代码使用权限

android - 我的 Android 应用程序需要 Play 商店中的 "Other"权限 - 这意味着什么以及如何修复?

android - 切换android Activity 时的致命信号6(SIGABRT)

android - 指定的 child 已经有一个 parent ,RecyclerView

Android Studio v1.3 检查未经检查的权限使用情况

java - 即使我声明了 Android 权限也不起作用

android 5.0 在打开相机时要求安全警告