[Android] PermissionUtil

Usage

PermissionUtil.with(this) // Activity or Fragment
    .addPermission(Manifest.permission.CAMERA)
    .setCallback(new PermissionUtil.Callback() {
        @Override
        public void onPermissionGranted(String[] permissions) {
            Log.d(TAG, "onPermissionGranted() called with: permissions = [" + dumpPermissions(permissions) + "]");
        }

        @Override
        public void onPermissionDenied(String[] permissions) {
            Log.d(TAG, "onPermissionDenied() called with: permissions = [" + dumpPermissions(permissions) + "]");
        }
    })
    .request();

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    // don't forget
    PermissionUtil.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}

Gradle

compile 'com.legendmohe.maven:permissionutil:0.2'

Download

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据