This library allows the usage of Kotlin with the new Android M permission model.
To use this library your minSdkVersion
must be >= 14.
Create a KPermissions
instance :
var kPermission: KPermission = KPermission(this) // where this is an Activity instance
Example : request the CAMERA permission
kPermission.requestPermission(arrayOf(Manifest.permission.CAMERA), {
Log.i(TAG, "isAllow---$it")
}, {
Log.i(TAG, "permission---$it")
})
You can need add callback in 'onRequestPermissionsResult' :
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
kPermission.onRequestPermissionsResult(requestCode, permissions, grantResults)
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
It can been use in Java.
Look at the sample
app for more.