Android高版本适配总结1


如有转载,请申明:
转载至 http://blog.csdn.net/qq_35064774/article/details/52950674


目录

  1. 权限适配
  2. 写短信操作适配
  3. 拦截短信操作适配
  4. 查看App使用情况适配
  5. 获取所有运行的App
  6. 清除App缓存

权限适配(安卓6.0 API api23)

安卓6.0给权限进行了分类,所以就出现了运行时权限。运行时权限需要在代码中申请。
这里我收集了一份 Android 6.0的运行时权限

如果你的App涉及的运行时权限很少,可以考虑在需要使用的时候再申请,如果申请成功,就运行相应的代码,申请失败就给出提示。
以下是申请权限的流程。

// check whether has specific permission
if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.READ_CONTACTS)
    == PackageManager.PERMISSION_GRANTED) {

    // has permission or no need permission

} else {
    // Should we show an explanation?
    if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
            Manifest.permission.READ_CONTACTS)) {

        // Show an expanation to the user *asynchronously* -- don't block
        // this thread waiting for the user's response! After the user
        // sees the explanation, try again to request the permission.

    } else {

        // No explanation needed, we can request the permission.
        ActivityCompat.requestPermissions(thisActivity,
                n
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值