Android Permission

Normal permission and Dangerous permission

• Normal permissions do not directly risk the user’s privacy. If your app lists a normal permission in its manifest, the system grants the permission automatically.
• Dangerous permissions can give the app access to the user’s confidential data. If your app lists a normal permission in its manifest, the system grants the permission automatically. If you list a dangerous permission, from Android 6.0, the user has to explicitly give approval to your app.

If target API less than 23:

• No matter what’s version OS is, all Permission in Manifest will be granted by System during installation. And users can see that.
• No matter what’s version OS is, deny the permission in Android settings screen can’t make any change. The permission is still granted. (For OS less than M, there might be no deny in settings screen.)

If target API higher or equal 23:

• Dangerous permissions should be granted during runtime by users. And they should also be declared in Manifest.
• If OS version higher or equal to M, users can see all the dangerous permission. But all of them are grey/off/denied by default. We should promote them and let users grant.
• Both ContextCompat in support library and native Activity have checkSelfPermission(),requestPermissions() and onRequestPermissionsResult() APIs to do runtime requesting.
• Only the permissions declared in manifest could be requested run time.
• Runtime permission is an additional requirement for targeting API higher than 23. It doesn’t enable developer more abilities but more restriction.
• If OS version lower than M, All dangerous permissions will be granted by system during installation.

Merged Manifest

In Android studio, there’s a tap at the bottom of Manifest file named “Merged Manifest” which could be used to check which libraries the permission is from.
Permission merged from libraries could be removed by tools:node=”remove” in main manifest.
could request permission specific for target API higher than or equal to 23. And for the situation that depending library targets API higher than 23 but main App targets API lower than 23, the dangerous permissions declared in depending library will be tagged as “<users-permission-sdk-23 ” automatically during merging.

External Storage Permission

  • Before API 18, developers need put READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE in manifest to read/write to application’s data folder.
  • After API 18, no permission needed to read/write to application’s data folder.

Some Scenarios No Permission Needed

  • To open/read file with Intent.ACTION_OPEN_DOCUMENT, no permission needed.
  • To open camera with ACTION_IMAGE_CAPTURE, no permission needed.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值