Android 6 以上版本运行时权限申请

23 May 2016

参考文档:
https://developer.android.com/training/permissions/index.html

Demo地址:
https://github.com/pulque/working-with-system-permissions

基本流程:
1.检查所有需要申请的权限。
2.有需要申请的权限,去向申请。
3.申请不到弹框提示。

使用方法:
1.在Activity中添加
    private PermissionHelper permissionHelper;
    public PermissionHelper getMPermission() {
        if (permissionHelper == null)
            permissionHelper = new PermissionHelper();
        return permissionHelper;
    }
    @Override
    public void onRequestPermissionsResult
    (int requestCode, @NonNull String[] permissions, 
                      @NonNull int[] grantResults) {
        super.onRequestPermissionsResult
                         (requestCode, permissions, grantResults);
        if (permissionHelper != null) {
            permissionHelper.onRequestPermissionsResult
            (this, requestCode, permissions, grantResults);
        }
    }
2.申请权限:
    PermissionHelper mPermission = getMPermission();
    mPermission.checkPermission(所在Activity, 完成后回调, 需要申请权限的列表);