I\'m trying to make my app ready for Android 6 and now I\'m stuck to the point where you need to request and check permissions.
I tried the following from the docs:
Trying to use checkSelfPermission()
in a Fragment
with Kotlin and wondering how to get around Context
being null?
Have a look at the sample below, and remember, before the Fragment
is attached to the Activity
, the Context
will be null.
private fun fineLocationPermissionApproved(): Boolean {
val context = context ?: return false
return PackageManager.PERMISSION_GRANTED == checkSelfPermission(
context,
Manifest.permission.ACCESS_FINE_LOCATION
)
}