/** * Creates a {@link GeofencingEvent} object from the given intent. * * @param intent the intent to extract the geofencing event data from * @return a {@link GeofencingEvent} object or {@code null} if the given intent is {@code null} */ public static GeofencingEvent fromIntent(Intent intent) { if (intent == null) { return null; } GeofencingEvent event = new GeofencingEvent(); event.errorCode = intent.getIntExtra(EXTRA_ERROR_CODE, -1); event.geofenceTransition = intent.getIntExtra(EXTRA_TRANSITION, -1); if (event.geofenceTransition != 1 && event.geofenceTransition != 2 && event.geofenceTransition != 4) event.geofenceTransition = -1; ArrayList<byte[]> parceledGeofences = (ArrayList<byte[]>) intent.getSerializableExtra(EXTRA_GEOFENCE_LIST); if (parceledGeofences != null) { event.triggeringGeofences = new ArrayList<Geofence>(); for (byte[] parceledGeofence : parceledGeofences) { event.triggeringGeofences.add(SafeParcelUtil.fromByteArray(parceledGeofence, ParcelableGeofence.CREATOR)); } } event.triggeringLocation = intent.getParcelableExtra(EXTRA_TRIGGERING_LOCATION); return event; }
/** * Creates a geofence object. * * @throws IllegalArgumentException if any parameters are not set or out of range */ public Geofence build() throws IllegalArgumentException { if (requestId == null) { throw new IllegalArgumentException("Request ID not set."); } else if (transitionTypes == 0) { throw new IllegalArgumentException("Transition types not set."); } else if ((transitionTypes & GEOFENCE_TRANSITION_DWELL) > 0 && loiteringDelay < 0) { throw new IllegalArgumentException("Non-negative loitering delay needs to be set when transition types include GEOFENCE_TRANSITION_DWELLING."); } else if (expirationTime == Long.MIN_VALUE) { throw new IllegalArgumentException("Expiration not set."); } else if (regionType == -1) { throw new IllegalArgumentException("Geofence region not set."); } else if (notificationResponsiveness < 0) { throw new IllegalArgumentException("Notification responsiveness should be nonnegative."); } else { return new ParcelableGeofence(requestId, expirationTime, regionType, latitude, longitude, radius, transitionTypes, notificationResponsiveness, loiteringDelay); } }
public void addGeofences(List<ParcelableGeofence> geofences, PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { Log.d(TAG, "addGeofences(List<ParcelableGeofence>)"); Intent i = new Intent(context, NativePendingIntentForwarder.class); Bundle bundle = new Bundle(); bundle.putParcelable(EXTRA_PENDING_INTENT, pendingIntent); i.putExtras(bundle); nativePendingMap.put(pendingIntent, PendingIntent.getActivity(context, 0, i, 0)); List<String> requestIds = new ArrayList<String>(); for (ParcelableGeofence geofence : geofences) { locationManager.addProximityAlert(geofence.latitude, geofence.longitude, geofence.radius, geofence.expirationTime - SystemClock.elapsedRealtime(), nativePendingMap.get(pendingIntent)); requestIds.add(geofence.getRequestId()); } callbacks.onAddGeofenceResult(CommonStatusCodes.SUCCESS, requestIds.toArray(new String[requestIds.size()])); }
public void addGeofences(List<ParcelableGeofence> request, PendingIntent pendingIntent, IGeofencerCallbacks callbacks) throws RemoteException { if (nativeLocation != null) { nativeLocation.addGeofences(request, pendingIntent, callbacks); } else { getServiceInterface().addGeofencesList(request, pendingIntent, callbacks, getContext().getPackageName()); } }
public GeofencingRequest(int paramInt1, List<ParcelableGeofence> paramList, int paramInt2) { this.a = paramInt1; this.b = paramList; this.c = paramInt2; }
@Override public void addGeofencesList(List<ParcelableGeofence> geofences, PendingIntent pendingIntent, IGeofencerCallbacks callbacks, String packageName) throws RemoteException { Log.d(TAG, "addGeofencesList: " + geofences); }
public abstract void a(List<ParcelableGeofence> paramList, PendingIntent paramPendingIntent, fcp paramfcp, String paramString);