public void requestLocationUpdates(LocationRequest request, final LocationListener listener) throws RemoteException { if (nativeLocation != null) { nativeLocation.requestLocationUpdates(request, listener); } else { if (!listenerMap.containsKey(listener)) { listenerMap.put(listener, new ILocationListener.Stub() { @Override public void onLocationChanged(Location location) throws RemoteException { listener.onLocationChanged(location); } }); } getServiceInterface().requestLocationUpdatesWithPackage(request, listenerMap.get(listener), getContext().getPackageName()); } }
public void removeLocationUpdates(ILocationListener listener, String packageName) { for (int i = 0; i < currentRequests.size(); i++) { if (currentRequests.get(i).respondsTo(listener)) { removeLocationUpdates(currentRequests.get(i)); i--; } } }
@Override public void requestLocationUpdatesWithListener(LocationRequest request, final ILocationListener listener) throws RemoteException { Log.d(TAG, "requestLocationUpdatesWithListener: " + request); getLocationManager().requestLocationUpdates(request, listener, null); }
@Override public void removeLocationUpdatesWithListener(ILocationListener listener) throws RemoteException { Log.d(TAG, "removeLocationUpdatesWithListener: " + listener); getLocationManager().removeLocationUpdates(listener, null); }
@Override public void requestLocationUpdatesWithPackage(LocationRequest request, ILocationListener listener, String packageName) throws RemoteException { Log.d(TAG, "requestLocationUpdatesWithPackage: " + request); getLocationManager().requestLocationUpdates(request, listener, packageName); }
@Override public void requestLocationUpdatesInternalWithListener(LocationRequestInternal request, ILocationListener listener) throws RemoteException { Log.d(TAG, "requestLocationUpdatesInternalWithListener: " + request); getLocationManager().requestLocationUpdates(request.request, listener, null); }
public LocationRequestHelper(Context context, LocationRequest locationRequest, boolean hasFinePermission, boolean hasCoarsePermission, String packageName, ILocationListener listener) { this(context, locationRequest, hasFinePermission, hasCoarsePermission, packageName); this.listener = listener; }
public boolean respondsTo(ILocationListener listener) { return this.listener != null && listener != null && this.listener.asBinder().equals(listener.asBinder()); }
public void requestLocationUpdates(LocationRequest request, ILocationListener listener, String packageName) { requestLocationUpdates(new LocationRequestHelper(context, request, hasFineLocationPermission(), hasCoarseLocationPermission(), packageName, listener)); }