I noticed that the LocationClient class is currently deprecated. I used it for a travel app. and I changed the logic of using LocationServices instead of LocationClient: https://developer.android.com/reference/com/google/android/gms/location/LocationServices.html
Now the problem is that I cannot get getTriggeringGeofences and getGeofenceTransition from LocationServices.Geofence or GoogleApiClient. How to do it?
This is the code of my old 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); }
source share