LocationClient クラスが現在廃止されていることに気付きました。旅行アプリで使っていました。LocationClient の代わりに LocationServices を使用するようにロジックを変更しました: https://developer.android.com/reference/com/google/android/gms/location/LocationServices.html
問題は、LocationServices.Geofence または GoogleApiClient から getTriggeringGeofences と getGeofenceTransition を取得できないことです。それ、どうやったら出来るの?
これは私の古い BroadcastReceiver のコードです。
int transitionType = LocationClient.getGeofenceTransition(intent);
if(transitionType == Geofence.GEOFENCE_TRANSITION_EXIT) {
List<Geofence> triggerList = LocationClient.getTriggeringGeofences(intent);
for (Geofence geofence : triggerList) {
Log.i("", "geof: " + transitionType + " GPS zone " + geofence.getRequestId());
if(geofence.getRequestId().contentEquals("1")) {
Utils.appendLog("GEOFENCE: exited current position GPS Zone");
MyApp.getInstance().disableGeofence();
addLoc();
}
}
}else if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER){
List<Geofence> triggerList = LocationClient.getTriggeringGeofences(intent);
for (Geofence geofence : triggerList) {
Log.i("", "geof: " + transitionType + " GPS zone " + geofence.getRequestId());
if(geofence.getRequestId().contentEquals("2")) {
Utils.appendLog("GEOFENCE: entered destination position GPS Zone");
MyApp.getInstance().disableGeofence();
}
}
}else{
Log.e("", "Geofence transition error: " + transitionType);
}