Java 类com.google.android.gms.location.GeofenceStatusCodes 实例源码

项目:SjekkUT    文件:GeofenceIntentService.java   
@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);
}
项目:Geoclock    文件:GeofenceReceiver.java   
@Override
public void onReceive(Context context, Intent intent) {
    final ActiveAlarmManager activeAlarmManager = new ActiveAlarmManager(context);

    GeofencingEvent event = GeofencingEvent.fromIntent(intent);
    if (event.hasError()) {
        final String errorMessage = GeofenceStatusCodes.getStatusCodeString(event.getErrorCode());
        Log.e(TAG, errorMessage);
        return;
    }

    final int transition = event.getGeofenceTransition();
    final List<Geofence> affectedGeofences = event.getTriggeringGeofences();

    if (null != affectedGeofences && !affectedGeofences.isEmpty()) {
        final Collection<GeoAlarm> affectedAlarms = filter(
                Lists.transform(affectedGeofences, getGeoAlarmForGeofenceFn(context)), a -> a != null);
        ImmutableSet<UUID> affectedAlarmIds = ImmutableSet.copyOf(transform(affectedAlarms, alarm -> alarm.id));
        if (transition == Geofence.GEOFENCE_TRANSITION_ENTER) {
            activeAlarmManager.addActiveAlarms(affectedAlarmIds);
        } else {
            activeAlarmManager.removeActiveAlarms(affectedAlarmIds);
        }
    }
}
项目:hypertrack-live-android    文件:ErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getGeofenceErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:Remindy    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:MyGeofencer    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:react-native-geo-fence    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return "Geofence service is not available now";
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return "Your app has registered too many geofences";
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return "You have provided too many PendingIntents to the addGeofences() call";
        default:
            return "Unknown error: the Geofence service is not available now";
    }
}
项目:EarthquakeSurvival    文件:LocationUtils.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return context.getString(R.string.geofence_error_unavailable);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return context.getString(R.string.geofence_error_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return context.getString(R.string.geofence_error_many_intents);
        default:
            return context.getString(R.string.geofence_error_unknown);
    }
}
项目:Didgeridone-Android    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:androidprojectbase    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:mobile-messaging-sdk-android    文件:GeoTransitionHelper.java   
/**
 * Resolves transition information from geofencing intent
 *
 * @param intent geofencing intent
 * @return transition information
 * @throws RuntimeException if information cannot be resolved
 */
static GeoTransition resolveTransitionFromIntent(Intent intent) throws RuntimeException {
    GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
    if (geofencingEvent == null) {
        throw new RuntimeException("Geofencing event is null, cannot process");
    }

    if (geofencingEvent.hasError()) {
        if (geofencingEvent.getErrorCode() == GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE) {
            throw new GeofenceNotAvailableException();
        }
        throw new RuntimeException("ERROR: " + GeofenceStatusCodes.getStatusCodeString(geofencingEvent.getErrorCode()));
    }

    GeoEventType event = supportedTransitionEvents.get(geofencingEvent.getGeofenceTransition());
    if (event == null) {
        throw new RuntimeException("Transition is not supported: " + geofencingEvent.getGeofenceTransition());
    }

    Set<String> triggeringRequestIds = new ArraySet<>();
    for (Geofence geofence : geofencingEvent.getTriggeringGeofences()) {
        triggeringRequestIds.add(geofence.getRequestId());
    }

    Location location = geofencingEvent.getTriggeringLocation();
    return new GeoTransition(event, triggeringRequestIds, new GeoLatLng(location.getLatitude(), location.getLongitude()));
}
项目:ProfileManager    文件:GeofenceErrorMessage.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
  Resources mResources = context.getResources();
  switch (errorCode) {
    case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
      return mResources.getString(R.string.geofence_not_available);
    case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
      return mResources.getString(R.string.geofence_too_many_geofences);
    case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
      return mResources.getString(R.string.geofence_too_many_pending_intents);
    default:
      return mResources.getString(R.string.unknown_geofence_error);
  }
}
项目:Locative-Android    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:io2015-codelabs    文件:GeofenceErrorMessages.java   
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return "Geofence service is not available now.";
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return "Your app has registered too many geofences.";
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return "You have provided too many PendingIntents!";
        default:
            return "Unknown error.";
    }
}
项目:io2015-codelabs    文件:GeofenceErrorMessages.java   
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return "Geofence service is not available now.";
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return "Your app has registered too many geofences.";
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return "You have provided too many PendingIntents!";
        default:
            return "Unknown error.";
    }
}
项目:FenceHouston    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:cominghome    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(@NonNull Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:android-play-location    文件:GeofenceErrorMessages.java   
/**
 * Returns the error string for a geofencing error code.
 */
public static String getErrorString(Context context, int errorCode) {
    Resources mResources = context.getResources();
    switch (errorCode) {
        case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
            return mResources.getString(R.string.geofence_not_available);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
            return mResources.getString(R.string.geofence_too_many_geofences);
        case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
            return mResources.getString(R.string.geofence_too_many_pending_intents);
        default:
            return mResources.getString(R.string.unknown_geofence_error);
    }
}
项目:android_external_GmsLib    文件:NativeLocationClientImpl.java   
public void addGeofences(GeofencingRequest geofencingRequest, PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException {
    Log.d(TAG, "addGeofences(GeofencingRequest)");
    callbacks.onAddGeofenceResult(GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE, new String[0]);
}
项目:android_external_GmsLib    文件:NativeLocationClientImpl.java   
public void removeGeofences(List<String> requestIds, IGeofencerCallbacks callbacks) throws RemoteException {
    Log.d(TAG, "removeGeofences(List<RequestId>)");
    callbacks.onRemoveGeofencesByRequestIdsResult(GeofenceStatusCodes.ERROR, requestIds.toArray(new String[requestIds.size()]));
}