We have access to user's GoogleApiClient
since he/she signed in from google account. Below code creates Geofence on user currently signed in. Example, User A logs into application and we have access to GoogleApiClient
, so geofence is created with addGeofences
function which takes parameter as mGoogleApiClient(current user's GoogleApiClient).
How can I create geofence on User B? How can I have access to his/her GoogleApiClient to create geofence on User B? In short, how can we create geofence on 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);
}
}