本文整理匯總了Java中com.google.android.gms.location.Geofence.GEOFENCE_TRANSITION_DWELL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Geofence.GEOFENCE_TRANSITION_DWELL屬性的具體用法?Java Geofence.GEOFENCE_TRANSITION_DWELL怎麽用?Java Geofence.GEOFENCE_TRANSITION_DWELL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.google.android.gms.location.Geofence
的用法示例。
在下文中一共展示了Geofence.GEOFENCE_TRANSITION_DWELL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleLogTransition
private void handleLogTransition(int geofenceTransition) {
String transitionStr = "";
switch (geofenceTransition) {
case Geofence.GEOFENCE_TRANSITION_ENTER:
transitionStr = "GEOFENCE_TRANSITION_ENTER";
break;
case Geofence.GEOFENCE_TRANSITION_EXIT:
transitionStr = "GEOFENCE_TRANSITION_EXIT";
break;
case Geofence.GEOFENCE_TRANSITION_DWELL:
transitionStr = "GEOFENCE_TRANSITION_DWELL";
break;
}
Log.d(TAG, transitionStr + " detected! ");
}
示例2: onHandleIntent
@Override
protected void onHandleIntent(Intent intent) {
GeofencingEvent fenceEvent = GeofencingEvent.fromIntent(intent);
if (fenceEvent.hasError()) {
String errorMessage = GeofenceStatusCodes.getStatusCodeString(fenceEvent.getErrorCode());
Timber.i(errorMessage);
return;
}
Timber.i("We got a geofence intent");
if (fenceEvent.getGeofenceTransition() != Geofence.GEOFENCE_TRANSITION_DWELL
|| fenceEvent.getTriggeringGeofences().isEmpty()) {
return;
}
String placeId = fenceEvent.getTriggeringGeofences().get(0).getRequestId();
Realm realm = Realm.getDefaultInstance();
Place place = Place.findFirst(realm, placeId);
String title = place != null ?
getString(R.string.geofence_notification_place_title, place.getName()) :
getString(R.string.geofence_notification_title);
String content = getString(R.string.geofence_notification_content);
String imageUrl = place != null ? place.getFirstImage(GEOFENCE_LARGE_ICON_SIZE) : null;
realm.close();
sendNotification(title, content, placeId, imageUrl);
}
示例3: getTransitionString
/**
0* 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_ENTER:
Log.d(TAG, "entered");
return getString(R.string.geofence_transition_entered);
case Geofence.GEOFENCE_TRANSITION_EXIT:
Log.d(TAG, "exited");
return getString(R.string.geofence_transition_exited);
case Geofence.GEOFENCE_TRANSITION_DWELL:
Log.d(TAG, "dwelling");
return ("In the area");
default:
Log.e(TAG, "unknown transition");
return getString(R.string.unknown_geofence_transition);
}
}
示例4: onHandleIntent
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
if (geofencingEvent.hasError()) {
String errorMessage = ErrorMessages.getGeofenceErrorString(this,
geofencingEvent.getErrorCode());
HyperLog.e(TAG, errorMessage);
return;
}
// Get the transition type.
int geofenceTransition = geofencingEvent.getGeofenceTransition();
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_DWELL) {
HyperLog.i(TAG, "User is dwelling in geo fence.");
ActionManager.getSharedManager(getApplicationContext()).OnGeoFenceSuccess();
} else {
// Log the error.
HyperLog.e(TAG, getString(R.string.geofence_transition_invalid_type,
geofenceTransition));
}
// Get the geofences that were triggered. A single event can trigger
// multiple geofences.
String geofenceTransitionDetails = getGeofenceTransitionDetails(geofenceTransition,
geofencingEvent.getTriggeringGeofences());
HyperLog.i(TAG, "GeoFenceTransition Details: " + geofenceTransitionDetails);
}
}
示例5: getTransitionString
/**
* 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_ENTER:
return getString(R.string.geofence_transition_entered);
case Geofence.GEOFENCE_TRANSITION_EXIT:
return getString(R.string.geofence_transition_exited);
case Geofence.GEOFENCE_TRANSITION_DWELL:
return getString(R.string.geofence_transition_dwelled);
default:
return getString(R.string.unknown_geofence_transition);
}
}
示例6: transitionString
public static String transitionString(@NonNull final GeofencingEvent geofencingEvent) {
int transitionCode = geofencingEvent.getGeofenceTransition();
if (transitionCode == Geofence.GEOFENCE_TRANSITION_EXIT)
return "EXIT";
else if (transitionCode == Geofence.GEOFENCE_TRANSITION_ENTER)
return "ENTER";
else if (transitionCode == Geofence.GEOFENCE_TRANSITION_DWELL)
return "DWELL";
else
return "UNKNOWN";
}
示例7: getStatusForTransitionType
private int getStatusForTransitionType(int transitionType) {
if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER ||
transitionType == Geofence.GEOFENCE_TRANSITION_DWELL) {
return GeofenceStatus.INSIDE;
} else {
return GeofenceStatus.OUTSIDE;
}
}
示例8: getGeofenceNotificationTitle
private String getGeofenceNotificationTitle(int geofenceTransition, Geofence triggeringGeofence) {
String transition = "";
switch (geofenceTransition) {
case Geofence.GEOFENCE_TRANSITION_ENTER:
transition = getResources().getString(R.string.notification_service_geofence_enter);
break;
case Geofence.GEOFENCE_TRANSITION_EXIT:
transition = getResources().getString(R.string.notification_service_geofence_exit);
break;
case Geofence.GEOFENCE_TRANSITION_DWELL:
//transition = getResources().getString(R.string.notification_service_geofence_dwell);
transition = getResources().getString(R.string.notification_service_geofence_enter);
break;
}
int placeId = Integer.valueOf(triggeringGeofence.getRequestId());
try {
Place place = new RemindyDAO(this).getPlace(placeId);
return String.format(Locale.getDefault(),
getResources().getString(R.string.notification_service_geofence_title),
transition,
place.getAlias());
} catch (PlaceNotFoundException e) {
return "";
}
}
示例9: getTransitionTypes
public static int getTransitionTypes(boolean entry, boolean exit) {
if (entry && exit) {
return Geofence.GEOFENCE_TRANSITION_ENTER |
Geofence.GEOFENCE_TRANSITION_EXIT |
Geofence.GEOFENCE_TRANSITION_DWELL;
} else if (entry) {
return Geofence.GEOFENCE_TRANSITION_ENTER |
Geofence.GEOFENCE_TRANSITION_DWELL;
} else if (exit) {
return Geofence.GEOFENCE_TRANSITION_EXIT |
Geofence.GEOFENCE_TRANSITION_DWELL;
} else {
return Geofence.GEOFENCE_TRANSITION_DWELL;
}
}
示例10: getGeofenceTransition
public GeoPointEventType getGeofenceTransition(GeofencingEvent geofencingEvent) {
if (!geofencingEvent.hasError()) {
int transition = geofencingEvent.getGeofenceTransition();
switch (transition) {
case Geofence.GEOFENCE_TRANSITION_ENTER:
return GeoPointEventType.ENTER;
case Geofence.GEOFENCE_TRANSITION_DWELL:
return GeoPointEventType.STAY;
case Geofence.GEOFENCE_TRANSITION_EXIT:
return GeoPointEventType.EXIT;
}
}
throw new GeofenceEventException("Geofence Event Error was produced, code is: " + geofencingEvent.getErrorCode());
}
示例11: addGeofence
private void addGeofence(boolean defaultReceiver, HashMap<String, Object> additionalData) {
String geoId;
String receiverClassName;
if (defaultReceiver) {
geoId = GEOFENCE_ID_FOR_DEFAULT_RECEIVER;
receiverClassName = null;
} else {
geoId = GEOFENCE_ID_FOR_CUSTOM_RECEIVER;
receiverClassName = CustomTransitionsIntentService.class.getName();
}
StorableGeofence storableGeofence = new StorableGeofence(
geoId,
receiverClassName,
mCurrentLocation.getLatitude(),
mCurrentLocation.getLongitude(),
200,
Geofence.NEVER_EXPIRE,
300000, // 5 minutes
Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT | Geofence.GEOFENCE_TRANSITION_DWELL,
additionalData);
boolean addedOnGoing = false;
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
addedOnGoing = mGeofenceManager.addGeofence(storableGeofence);
}
if (!addedOnGoing) {
Log.e(TAG, "Addition of geofence has been refused " + storableGeofence);
}
}
示例12: onHandleIntent
@Override
protected void onHandleIntent(Intent intent) {
String notificationText = "Not a geo event";
GeofencingEvent geoEvent = GeofencingEvent.fromIntent(intent);
if (geoEvent != null) {
if (geoEvent.hasError()) {
notificationText = "Error : " + geoEvent.getErrorCode();
} else {
int transition = geoEvent.getGeofenceTransition();
String transitionStr;
switch (transition) {
case Geofence.GEOFENCE_TRANSITION_ENTER:
transitionStr = "Enter-";
break;
case Geofence.GEOFENCE_TRANSITION_EXIT:
transitionStr = "Exit-";
break;
case Geofence.GEOFENCE_TRANSITION_DWELL:
transitionStr = "Dwell-";
break;
default:
transitionStr = "Unknown-";
}
List<Geofence> triggeringGeo = geoEvent.getTriggeringGeofences();
StringBuilder strBuilder = new StringBuilder();
strBuilder.append(transitionStr);
for (int i = 0; i < triggeringGeo.size(); i++) {
Geofence geo = triggeringGeo.get(i);
strBuilder.append(geo.getRequestId());
strBuilder.append("-");
}
notificationText = strBuilder.toString();
}
}
sendNotification(notificationText);
}
示例13: getTransitionString
/**
* 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";
}
}
示例14: getEventType
@Nullable
private EventType getEventType(int transitionType) {
switch (transitionType) {
case Geofence.GEOFENCE_TRANSITION_ENTER:
return EventType.ENTER;
case Geofence.GEOFENCE_TRANSITION_EXIT:
return EventType.EXIT;
case Geofence.GEOFENCE_TRANSITION_DWELL:
return EventType.ENTER;
default:
return null;
}
}
示例15: getTransitionTypeString
private String getTransitionTypeString(int transitionType) {
switch (transitionType) {
case Geofence.GEOFENCE_TRANSITION_ENTER:
return mContext.getString(R.string.entered);
case Geofence.GEOFENCE_TRANSITION_EXIT:
return mContext.getString(R.string.left);
case Geofence.GEOFENCE_TRANSITION_DWELL:
return mContext.getString(R.string.entered);
default:
return mContext.getString(R.string.visited);
}
}