We have access to the GoogleApiClient
user since logging in to google account. The code below creates Geofence for the user who is currently registered. Example: user A is registered in the application, and we have access to GoogleApiClient
, so the geofence is created using the addGeofences
function, which takes the parameter as mGoogleApiClient (current GoogleApiClient user).
How can I create geofence for user B? How can I access his / her GoogleApiClient to create a geo object in User B? In short, how can we create geofence for other users? Please help!
public void addGeofencesButtonHandler(View view) { if (!mGoogleApiClient.isConnected()) { Toast.makeText(this, getString(R.string.not_connected), Toast.LENGTH_SHORT).show(); return; } try { populateGeofenceList();// creates geofence from list 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); } }
source share