Is a library that helps to handle runtime permissions on Android, entirely written using Kotlin language.
StartaskPermissions is a library that helps to handle runtime permissions on Android, entirely written using Kotlin language.
The library is published to JitPack repository.
allprojects {
repositories {
//...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation "com.github.illiashenkoo:startask-permissions:${latest.version}"
}
<uses-permission android:name="android.permission.CAMERA" />
Permission
objectprivate val permission: Permission by lazy {
Permission.Builder(Manifest.permission.CAMERA)
.setRequestCode(MY_PERMISSIONS_REQUEST_CODE)
.build()
}
permission.check(this)
.onGranted {
// All requested permissions are granted
}.onShowRationale {
// Provide an explanation if the user has already denied that permission request
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
permission.onRequestPermissionsResult(this, requestCode, grantResults)
.onGranted {
// All requested permissions are granted
}.onDenied {
// Oops, some of the permissions are denied
}.onNeverAskAgain {
// Oops, some of the permissions are denied
// User chose "never ask again" about a permission
}
}
Look at the examples of using the library
All development (both new features and bug fixes) is performed in develop
branch.
This way master
sources always contain sources of the most recently released version.
Please send PRs with bug fixes to develop
branch.
Fixes to documentation in markdown files are an exception to this rule. They are updated directly in master
.
The develop
branch is pushed to master
during release.