在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):pankaj89/PermissionHelper开源软件地址(OpenSource Url):https://github.com/pankaj89/PermissionHelper开源编程语言(OpenSource Language):Kotlin 50.3%开源软件介绍(OpenSource Introduction):Permission HelperPermissionHelper used to simplfy Runtime Permission Structure.
Latest Version [2.3]
DownloadIn root level build.gradle
Include the following dependency in your apps level build.gradle file.
How to useIn KotlinpermissionHelper = PermissionHelper(this, arrayOf(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CALL_PHONE), 100)
permissionHelper?.denied {
if (it) {
Log.d(TAG, "Permission denied by system")
permissionHelper?.openAppDetailsActivity()
} else {
Log.d(TAG, "Permission denied")
}
}
//Request all permission
permissionHelper?.requestAll {
Log.d(TAG, "All permission granted")
}
//Request individual permission
permissionHelper?.requestIndividual {
Log.d(TAG, "Individual Permission Granted")
} In JavapermissionHelper = new PermissionHelper(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
permissionHelper.request(new PermissionHelper.PermissionCallback() {
@Override
public void onPermissionGranted() {
Log.d(TAG, "onPermissionGranted() called");
}
@Override
public void onIndividualPermissionGranted(String[] grantedPermission) {
Log.d(TAG, "onIndividualPermissionGranted() called with: grantedPermission = [" + TextUtils.join(",",grantedPermission) + "]");
}
@Override
public void onPermissionDenied() {
Log.d(TAG, "onPermissionDenied() called");
}
@Override
public void onPermissionDeniedBySystem() {
Log.d(TAG, "onPermissionDeniedBySystem() called");
}
}); Override onRequestPermissionsResult@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (permissionHelper != null) {
permissionHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
} My Other Libraries(link)Simple Adapter for RecyclerView(link)LocationHelper(link)MasterExoPlayer (Play video inside RecyclerView)License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论