Answer the question
In order to leave comments, you need to log in
Problem with google policy to use geolocation from background?
They are trying to change the application code so that everything complies with the new Google policy regarding access to geolocation from
https://support.google.com/googleplay/android-deve...
One activity is used with many fragments.
The application immediately opens the map and searches for the user's location using FusedLocationProviderClient
minSdkVersion 23
targetSdkVersion 29
val highAccuracyLocationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval((10 * 1000).toLong())
.setFastestInterval((1 * 1000).toLong())
fusedLocationClient?.requestLocationUpdates(
highAccuracyLocationRequest,
locationCallback,
null
)
locationCallback = object : LocationCallback() {
override fun onLocationResult(locationResult: LocationResult?) {
for (location in locationResult!!.locations) {
success(location)
stopLocationUpdates()
}
}
}
fun stopLocationUpdates() {
if (locationCallback != null)
fusedLocationClient?.removeLocationUpdates(locationCallback)
}
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
tools:node="remove" />
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question