當前位置: 首頁>>代碼示例>>Java>>正文


Java Geofence.GEOFENCE_TRANSITION_DWELL屬性代碼示例

本文整理匯總了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! ");
    }
 
開發者ID:abicelis,項目名稱:Remindy,代碼行數:16,代碼來源:GeofenceNotificationIntentService.java

示例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);
}
 
開發者ID:Turistforeningen,項目名稱:SjekkUT,代碼行數:26,代碼來源:GeofenceIntentService.java

示例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);
    }
}
 
開發者ID:arshiyakhanum,項目名稱:ProfileManager,代碼行數:24,代碼來源:GeofenceTransitionIntentService.java

示例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);
    }
}
 
開發者ID:hypertrack,項目名稱:hypertrack-live-android,代碼行數:31,代碼來源:GeofenceTransitionsIntentService.java

示例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);
    }
}
 
開發者ID:hypertrack,項目名稱:hypertrack-live-android,代碼行數:18,代碼來源:GeofenceTransitionsIntentService.java

示例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";
}
 
開發者ID:bsautermeister,項目名稱:GeoFencer,代碼行數:11,代碼來源:GeofenceUtils.java

示例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;
  }
}
 
開發者ID:Leanplum,項目名稱:Leanplum-Android-SDK,代碼行數:8,代碼來源:LocationManagerImplementation.java

示例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 "";
    }


}
 
開發者ID:abicelis,項目名稱:Remindy,代碼行數:29,代碼來源:GeofenceNotificationIntentService.java

示例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;
    }
}
 
開發者ID:Orchextra,項目名稱:orchextra-android-sdk,代碼行數:15,代碼來源:GeofenceUtils.java

示例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());
}
 
開發者ID:Orchextra,項目名稱:orchextra-android-sdk,代碼行數:14,代碼來源:AndroidGeofenceIntentServiceHandler.java

示例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);
    }
}
 
開發者ID:djavan-bertrand,項目名稱:GeofenceHelper,代碼行數:30,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:djavan-bertrand,項目名稱:GeofenceHelper,代碼行數:39,代碼來源:DefaultTransitionsIntentService.java

示例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";
    }
}
 
開發者ID:Power-Switch,項目名稱:PowerSwitch_Android,代碼行數:18,代碼來源:GeofenceIntentService.java

示例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;
    }

}
 
開發者ID:LocativeHQ,項目名稱:Locative-Android,代碼行數:14,代碼來源:TriggerManager.java

示例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);
    }
}
 
開發者ID:LocativeHQ,項目名稱:Locative-Android,代碼行數:12,代碼來源:NotificationManager.java


注:本文中的com.google.android.gms.location.Geofence.GEOFENCE_TRANSITION_DWELL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。