如有转载,请申明:
转载至 http://blog.csdn.net/qq_35064774/article/details/52950674
目录
- 权限适配
- 写短信操作适配
- 拦截短信操作适配
- 查看App使用情况适配
- 获取所有运行的App
- 清除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