Skip to content

Instantly share code, notes, and snippets.

@FilHazer
Created January 22, 2016 17:05
Show Gist options
  • Save FilHazer/7bc51e90f630421e7953 to your computer and use it in GitHub Desktop.
Save FilHazer/7bc51e90f630421e7953 to your computer and use it in GitHub Desktop.
public class GeoIntentService extends IntentService{
private String LOG_TAG = "DEBUG";
public GeoIntentService() {
super("GeoIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
Log.i(LOG_TAG, "onHandleIntent");
GeofencingEvent event = GeofencingEvent.fromIntent(intent);
if (event == null) {
return;
}
if (event.hasError()) {
Log.i(LOG_TAG, "ERROR");
return;
}
int transition = event.getGeofenceTransition();
if (transition == Geofence.GEOFENCE_TRANSITION_ENTER){
Log.i(LOG_TAG, "ENTER");
} else if(transition == Geofence.GEOFENCE_TRANSITION_DWELL ){
Log.i(LOG_TAG, "DWELL");
}else if(transition == Geofence.GEOFENCE_TRANSITION_EXIT) {
Log.i(LOG_TAG, "EXIT");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment