---
title: "Android 6.0 运行时权限处理完全解析-兼容"
author: "喧嚣求静"
date: "2016-07-21T10:12:08Z"
tags: []
categories: ["移动开发"]
slug: "android-6-0"
draft: false
lastmod: "2016-07-21T10:12:08Z"
id: 2312576
url: "https://913.iteye.com/blog/2312576"
---

1.项目增加V7包，\*Activity extends AppCompatActivity

if (ContextCompat.checkSelfPermission(this,  
                Manifest.permission.CALL\_PHONE)  
                != PackageManager.PERMISSION\_GRANTED)  
        {

            ActivityCompat.requestPermissions(this,  
                    new String\[]{Manifest.permission.CALL\_PHONE},  
                    MY\_PERMISSIONS\_REQUEST\_CALL\_PHONE);  
        } else  
        {  
            callPhone();  
        }  
2.在使用的危险权限时，检测权限

3.使用第三方封装好的库

参考文档：

[http://blog.csdn.net/lmj623565791/article/details/50709663](http://blog.csdn.net/lmj623565791/article/details/50709663)

[https://github.com/lovedise/PermissionGen](https://github.com/lovedise/PermissionGen)