使Android权限意味着另一个权限

时间:2017-01-11 15:33:45

标签: android android-permissions

我在我的应用程序中声明了新的权限,一个用于读访问,一个用于写访问。有没有办法写权限可以暗示读权限?这样,如果应用程序请求写入权限,则会自动获得读取权限。

这是我的清单代码:

<permission
    android:name="com.example.myapp.permission.CHANGE_MESSAGE"
    android:description="@string/permission_change_message"
    android:protectionLevel="dangerous" />
<permission
    android:name="com.example.myapp.permission.READ_MESSAGE"
    android:description="@string/permission_read_message"
    android:protectionLevel="normal" />

我想让任何有CHANGE_MESSAGE权限的应用也可以READ_MESSAGE获得权限,而无需明确声明READ_MESSAGE

1 个答案:

答案 0 :(得分:0)

我还没有使用自定义Permission但是你可以试试这个:

  • Permission Name One------->Point to one Activity--(m1(),m2(),m3())

  • Permission Name Two------->Point to Second Activity--(m4(),m5(),m6())

假设我们希望在系统授权Permission名称一时向用户授予Permission名称二的权限。然后你可以从Activity名称一点Permission内部调用m4(),m5(),m6()。