Googleアカウントからサインインしているので、ユーザーのGoogleApiClient
にアクセスできます。以下のコードでは、現在ログインしているユーザーにGeofenceが作成されます。例:ユーザーAがアプリケーションにログインし、GoogleApiClient
にアクセスできるので、geFenceはaddGeofences
関数で作成され、パラメータはmGoogleApiClient(現在のユーザーのGoogleApiClient)となります。異なるユーザーにGeofenceを作成する
ユーザBにジオフェンスを作成するにはどうすればよいですか?ユーザーBにジオフェンスを作成するには、GoogleApiClientにどのようにアクセスできますか?つまり、他のユーザーにジオフェンスを作成するにはどうすればいいですか?助けてください!
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);
}
}