등록된 서비스에서 이벤트가 발생합니다.
@Override
protected void onHandleIntent(Intent intent) {
GeofencingEvent geoFenceEvent = GeofencingEvent.fromIntent(intent);
if (geoFenceEvent.hasError()) {
int errorCode = geoFenceEvent.getErrorCode();
Log.e(TAG, "Location Services error: " + errorCode);
} else {
int transitionType = geoFenceEvent.getGeofenceTransition();
String triggeredGeoFenceId = geoFenceEvent.getTriggeringGeofences().get(0)
.getRequestId();
Logger.getLogger(TAG).debug("transitionType : " + transitionType);
if (Geofence.GEOFENCE_TRANSITION_ENTER == transitionType) {
currentLocation = ((SmartDrivingApp) getApplication()).getFirstLocation();
mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
Logger.getLogger(TAG).debug("진입 ~~~~~~~~~~~~~~~~: ");
} else if (Geofence.GEOFENCE_TRANSITION_EXIT == transitionType) {
mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
Logger.getLogger(TAG).debug("진출 ~~~~~~~~~~~~~~~~: ");
// showToast(this, "진출");
mGoogleApiClient.disconnect();
updateInOutGeofence("false", triggeredGeoFenceId);
}
}
}