Ho notato che la classe LocationClient è attualmente deprecata. Lo stavo usando per un'app di viaggio. e ho cambiato la logica di utilizzare LocationServices invece di LocationClient: https://developer.android.com/reference/com/google/android/gms/location/LocationServices.htmlgetTriggeringGeofences e getGeofenceTransition da LocationServices
Ora il problema è che non riesco a getTriggeringGeofences e getGeofenceTransition da LocationServices.Geofence, o il GoogleApiClient. Come lo faccio?
Questo è il codice dal mio vecchio 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);
}
Non c'è assolutamente alcun esempio di ottenere le recinzioni innescate senza utilizzare il LocationClient deprecato: | Il più vicino alla documentazione che ho trovato è questo https://github.com/jdellinger/AnDevConNov2014-LocationServicesDemoProject/tree/newapi - ma utilizza ancora il LocationClient per raccogliere i trigger di fence – InquisitorJax