List of usage examples for android.location LocationManager KEY_PROVIDER_ENABLED
String KEY_PROVIDER_ENABLED
To view the source code for android.location LocationManager KEY_PROVIDER_ENABLED.
Click Source Link
From source file:com.mfcoding.locationBP.receivers.LocationChangedReceiver.java
/** * When a new location is received, extract it from the Intent and use * it to start the Service used to update the list of nearby places. * // w w w .j a v a 2 s .c om * This is the Active receiver, used to receive Location updates when * the Activity is visible. */ @Override public void onReceive(Context context, Intent intent) { String locationKey = LocationManager.KEY_LOCATION_CHANGED; String providerEnabledKey = LocationManager.KEY_PROVIDER_ENABLED; if (intent.hasExtra(providerEnabledKey)) { if (!intent.getBooleanExtra(providerEnabledKey, true)) { Intent providerDisabledIntent = new Intent( PlacesConstants.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED); context.sendBroadcast(providerDisabledIntent); } } if (intent.hasExtra(locationKey)) { Location location = (Location) intent.getExtras().get(locationKey); Log.d(TAG, "Actively Updating location lat:" + location.getLatitude() + " lng:" + location.getLongitude()); Intent updateServiceIntent = new Intent(context, PlacesConstants.SUPPORTS_ECLAIR ? EclairPlacesUpdateService.class : LocationUpdateService.class); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_LOCATION, location); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_RADIUS, PlacesConstants.DEFAULT_RADIUS); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_FORCEREFRESH, true); context.startService(updateServiceIntent); // Intent locUpdateIntent = new Intent(PlacesConstants.ACTIVE_LOCATION_UPDATE); // context.sendBroadcast(locUpdateIntent); } }
From source file:org.smap.smapTask.android.receivers.LocationChangedReceiver.java
/** * When a new location is received, extract it from the Intent and use * TODO start a service to handle new location * *///from ww w . ja va 2 s.c o m @Override public void onReceive(Context context, Intent intent) { String locationKey = LocationManager.KEY_LOCATION_CHANGED; String providerEnabledKey = LocationManager.KEY_PROVIDER_ENABLED; if (intent.hasExtra(providerEnabledKey)) { if (!intent.getBooleanExtra(providerEnabledKey, true)) { Log.i(TAG, "===================== Provider disabled"); if (!intent.getBooleanExtra(providerEnabledKey, true)) { Intent providerDisabledIntent = new Intent( "org.smap.smapTask.android.active_location_update_provider_disabled"); context.sendBroadcast(providerDisabledIntent); } } } if (intent.hasExtra(locationKey)) { Location location = (Location) intent.getExtras().get(locationKey); if (isValidLocation(location) && isAccurateLocation(location)) { Log.d(TAG, "============== Updating location"); // Save the current location Collect.getInstance().setLocation(location); // Notify any activity interested that there is a new location LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("locationChanged")); // Save the location in the database if (settings == null) { settings = PreferenceManager.getDefaultSharedPreferences(context); } if (settings.getBoolean(PreferencesActivity.KEY_STORE_USER_TRAIL, false)) { TraceUtilities.insertPoint(location); } } } }