Answer the question
In order to leave comments, you need to log in
Why isn't a SecurityException thrown when using FusedLocationProviderClient?
//в Activity
override fun onStart() {
super.onStart()
val res = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)== PackageManager.PERMISSION_GRANTED
Log.d(TAG, "ACCESS_FINE_LOCATION: $res") //<=== тут false
var fusedLocationProviderClient: FusedLocationProviderClient? = null
val locationCallback = LocationCallback()
try {
fusedLocationProviderClient= LocationServices.getFusedLocationProviderClient(this)
fusedLocationProviderClient.requestLocationUpdates(LocationRequest(), locationCallback, Looper.myLooper())
} catch (e: Throwable) { //<==== почему нет SecurityException? (и вообще любого Exception?)
Log.d(TAG, e.javaClass.name)
} finally {
fusedLocationProviderClient?.removeLocationUpdates(locationCallback)
fusedLocationProviderClient = null
}
}
Answer the question
In order to leave comments, you need to log in
Well, after checking and getting PERMISSION_DENIED, you need to explicitly request a permishin.
https://developer.android.com/training/permissions...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question