Package com.fondesa.kpermissions.extension

Functions

checkPermissionsStatus
Link copied to clipboard
fun Activity.checkPermissionsStatus(firstPermission: String, vararg otherPermissions: String): List<PermissionStatus>

Checks the status of the permissions without sending a request. Below API 23, the permission status can be PermissionStatus.Granted or PermissionStatus.Denied.Permanently depending on the presence of the permission in the manifest. Above API 23, when runtime permissions are necessary, the client doesn't know if a permission is permanently denied or it was never asked to the user. In this case the returned status is PermissionStatus.RequestRequired.

isPermissionGranted
Link copied to clipboard
fun Context.isPermissionGranted(permission: String): Boolean

Convenience method to check if a permission is granted or not. This method is compatible with all API versions.

liveData
Link copied to clipboard
fun PermissionRequest.liveData(): LiveData<List<PermissionStatus>>

Observes the PermissionRequest's status. The returned LiveData emits the list of PermissionStatus when the result of PermissionRequest.send is received. The documentation of the possible values of PermissionStatus can be found at PermissionRequest.Listener.onPermissionsResult.

permissionsBuilder
Link copied to clipboard
fun Fragment.permissionsBuilder(firstPermission: String, vararg otherPermissions: String): PermissionRequestBuilder

Creates the default PermissionRequestBuilder using the context of the Activity at which this Fragment is attached. The builder will use the default configurations and will be provided with the set of firstPermission plus otherPermissions attached to it.

fun FragmentActivity.permissionsBuilder(firstPermission: String, vararg otherPermissions: String): PermissionRequestBuilder

Creates the default PermissionRequestBuilder using the context of the Activity. The builder will use the default configurations and will be provided with the set of otherPermissions attached to it.

send
Link copied to clipboard
inline fun PermissionRequest.send(crossinline callback: (List<PermissionStatus>) -> Unit)

Sends the PermissionRequest and performs the checks on its status. The result will be returned in the given callback.