У нас есть доступ к пользовательскому GoogleApiClient
с момента его подписания с учетной записи google. Ниже код создает Geofence для пользователя, который в настоящее время подписан. Пример: пользователь A регистрируется в приложении, и у нас есть доступ к GoogleApiClient
, поэтому геофенсирование создается с помощью функции addGeofences
, которая принимает параметр как mGoogleApiClient (текущий пользовательский API Google Analytics).Создание Geofence для разных пользователей
Как создать геозонность для пользователя B? Как я могу получить доступ к его/ее GoogleApiClient для создания геообъекта в User B? Короче говоря, как мы можем создать геозонность для других пользователей? Пожалуйста помоги!
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);
}
}