public static final String GPS_PROVIDER = "gps";
/**
+ * A special location provider for receiving locations without actually initiating
+ * a location fix. This provider can be used to passively receive location updates
+ * when other applications or services request them without actually requesting
+ * the locations yourself. This provider will return locations generated by other
+ * providers. You can query the {@link Location#getProvider()} method to determine
+ * the origin of the location update.
+ *
+ * Requires the permission android.permission.ACCESS_FINE_LOCATION, although if the GPS
+ * is not enabled this provider might only return coarse fixes.
+ */
+ public static final String PASSIVE_PROVIDER = "passive";
+
+ /**
* Key used for the Bundle extra holding a boolean indicating whether
* a proximity alert is entering (true) or exiting (false)..
*/
List<String> providers = getProviders(enabledOnly);
for (String providerName : providers) {
LocationProvider provider = getProvider(providerName);
- if (provider.meetsCriteria(criteria)) {
+ if (provider != null && provider.meetsCriteria(criteria)) {
if (goodProviders.isEmpty()) {
goodProviders = new ArrayList<String>();
}
mListeners.put(listener, transport);
mService.requestLocationUpdates(provider, minTime, minDistance, transport);
}
- } catch (RemoteException ex) {
+ } catch (Exception ex) {
Log.e(TAG, "requestLocationUpdates: DeadObjectException", ex);
}
}