Java Code Examples for com.google.android.gms.location.Geofence#GEOFENCE_TRANSITION_DWELL

The following examples show how to use com.google.android.gms.location.Geofence#GEOFENCE_TRANSITION_DWELL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeofenceIntentService.java    From Android-9-Development-Cookbook with MIT License 5 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
    if (geofencingEvent.hasError()) {
        Toast.makeText(getApplicationContext(), "Geofence error code= "
                        + geofencingEvent.getErrorCode(), Toast.LENGTH_SHORT).show();
        return;
    }
    int geofenceTransition = geofencingEvent.getGeofenceTransition();
    if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_DWELL) {
        Toast.makeText(getApplicationContext(), "GEOFENCE_TRANSITION_DWELL",
                Toast.LENGTH_SHORT).show();
    }
}
 
Example 2
Source File: LocationManagerImplementation.java    From Leanplum-Android-SDK with Apache License 2.0 5 votes vote down vote up
private int getStatusForTransitionType(int transitionType) {
  if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER ||
      transitionType == Geofence.GEOFENCE_TRANSITION_DWELL) {
    return GeofenceStatus.INSIDE;
  } else {
    return GeofenceStatus.OUTSIDE;
  }
}
 
Example 3
Source File: GeofenceIntentService.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Maps geofence transition types to their human-readable equivalents.
 *
 * @param transitionType A transition type constant defined in Geofence
 * @return A String indicating the type of transition
 */
private String getTransitionString(int transitionType) {
    switch (transitionType) {
        case Geofence.GEOFENCE_TRANSITION_DWELL:
            return "dwell";
        case Geofence.GEOFENCE_TRANSITION_ENTER:
            return getString(R.string.enter);
        case Geofence.GEOFENCE_TRANSITION_EXIT:
            return getString(R.string.exit);
        default:
            return "Unknown Transition";
    }
}