Android 权限使用问题

这是一个问题贴,但是我的积分不够分不够发帖啦  ̄□ ̄||


答案

自定义权限:


 
 
 
<permission android:name="DeclarPermissionDangerous" android:description="@string/app_name" android:icon="@mipmap/ic_launcher" android:protectionLevel="dangerous" />

后来确定问题在于 android:name="permissionName"

经测试 permissionName 如果定义为 反向域风格reverse-domain-style(com.tom.permission) 即可正常使用。

Google 官方文档的意思是建议使用“反向域风格”,但是如果不使用会造成错误,这也是试验过才知道的。

  1. https://developer.android.google.cn/guide/topics/manifest/permission-element.html#nm




问题

我写了两个应用测试权限相关的功能细节

应用a 声明(创造)权限并用来保护自己的 Activity
应用b 声明(使用)权限并且调用应用 a 的 activity

应用 a 代码
AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="tom.work.foxmail.com.declarpermission">

    <permission
        android:name="DeclarPermissionNormal"
        android:description="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:protectionLevel="normal" />

    <permission
        android:name="DeclarPermissionDangerous"
        android:description="@strin
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值