A
A
Anton2021-04-07 18:00:58
Android
Anton, 2021-04-07 18:00:58

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)
    }


in the onPause() of the fragment, I also run stopLocationUpdates()

In the manifest, the following permissions (ACCESS_BACKGROUND_LOCATION explicitly prohibited):
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
        tools:node="remove" />


When you update the application, Google writes again and again that your application does not comply with the policy.
Perhaps I did not foresee all the conditions and forgot something?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bevsa, 2021-04-08
@bevsa

It is necessary to remove from the manifest any (including the prohibition) references to getting a location in the background.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question