mehmet
mehmet

Reputation: 1588

How to use GeofencingApi with just ACCESS_COARSE_LOCATION

I am trying to use geofencing but I dont want to get user exact location. so that I am using ACCESS_COARSE_LOCATION. if I use large geofence point circle I think ACCESS_COARSE_LOCATION will work properly. May be not work perfect but it will give aproximatly an idea about user location.

at docs code like this

        try {
        LocationServices.GeofencingApi.addGeofences(
                mGoogleApiClient,
                // The GeofenceRequest object.
                getGeofencingRequest(),
                // A pending intent that that is reused when calling removeGeofences(). This
                // pending intent is used to generate an intent when a matched geofence
                // transition is observed.
                getGeofencePendingIntent()
        ).setResultCallback(this); // Result processed in onResult().
    } catch (SecurityException securityException) {
        // Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
        logSecurityException(securityException);
    }

but it gives error because GeofencingApi.addGeofences needs to FINE_LOCATION permission. how can I use geofencing with COARSA_LOCATION

Upvotes: 2

Views: 279

Answers (1)

Giorgio Antonioli
Giorgio Antonioli

Reputation: 16214

You can't. You need ACCESS_FINE_LOCATION to use Geofencing API.

Quoting the documentation:

The first step in requesting geofence monitoring is to request the necessary permission. To use geofencing, your app must request ACCESS_FINE_LOCATION.

https://developer.android.com/training/location/geofencing.html#RequestGeofences

Upvotes: 2

Related Questions