LocationProvider gpsProvider = locationManager.getProvider(LocationManager.GPS_PROVIDER); if(gpsProvider != null) LocationProvider networkProvider = locationManager.getProvider(LocationManager.NETWORK_PROVIDER);; if(networkProvider != null) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000 * 60 * 5, 0, this);
private void checkGps() { LocationManager mLocService = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (mLocService != null) { LocationProvider mLocProvider = mLocService.getProvider(LocationManager.GPS_PROVIDER); if (mLocProvider == null) { hideGPSCategory(); } } }
private void setupMockLocations() { try { if(mLocationManager.getProvider( VEHICLE_LOCATION_PROVIDER) == null) { mLocationManager.addTestProvider(VEHICLE_LOCATION_PROVIDER, false, false, false, false, false, true, false, 0, 5); } mLocationManager.setTestProviderEnabled( VEHICLE_LOCATION_PROVIDER, true); } catch(SecurityException e) { Log.w(TAG, "Unable to use mocked locations, " + "insufficient privileges - make sure mock locations " + "are allowed in device settings", e); mLocationManager = null; } } }
//Instantiate in your activity LocationManager lm = getSystemService(LOCATION_SERVICE); //Add a test provider lm.addTestProvider("myprovider", false, false, false, false, true, true, true, Criteria.POWER_HIGH, Criteria.ACCURACY_FINE); //Update the last location your provider will serve Location fakeLoc = ...; lm.setTestProviderLocation("myprovider", fakeLoc); //Using your custom location provider LocationProvider customProvider = lm.getProvider("myprovider");
setContentView(R.layout.activity_main); LocationProvider provider = lm.getProvider("gps"); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
public void beginMonitoringLocation(int minDistance) { IntentFilter filter = new IntentFilter(); filter.addAction(MainActivity.LOCATION_UPDATE_ACTION); this.mContext.registerReceiver(this.locationReceiver, filter); LocationManager mLocationManager = (LocationManager) this.mContext.getSystemService(Context.LOCATION_SERVICE); mLocationManager.addGpsStatusListener(this); boolean enabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); if (!enabled) { Log.e("LocationManager", "GPS not enabled!!!!"); } LocationProvider provider = mLocationManager.getProvider(LocationManager.GPS_PROVIDER); // GET THE BEST PROVIDER FOR OUR LOCATION Log.d("LocationManager:","Location Provider:"+provider); if ( provider == null ) { Log.e( "LocationManager", "No location provider found!" ); return; } final int locationUpdateRC=0; int flags = 0; Intent intent = new Intent(MainActivity.LOCATION_UPDATE_ACTION); PendingIntent pendingIntent = PendingIntent.getBroadcast(this.mContext, locationUpdateRC, intent, flags); // PENDING INTENT TO BE FIRED WHEN THE LOCATIONMANAGER RECEIVES LOCATION UPDATE. // THIS PENDING INTENT IS CAUGHT BY OUR BROADCAST RECEIVER mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,minDistance,pendingIntent); this._monitoringLocation = true; }
LocationProvider gpsProvider = locationManager.getProvider(LocationManager.GPS_PROVIDER); if(gpsProvider != null) LocationProvider networkProvider = locationManager.getProvider(LocationManager.NETWORK_PROVIDER);; if(networkProvider != null) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000 * 60 * 5, 0, this);
private boolean gpsInit() { mLocService = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (mLocService != null) { mLocProvider = mLocService.getProvider(LocationManager.GPS_PROVIDER); if (mLocProvider != null) { mLocService.addGpsStatusListener(this); if (mLocService.isProviderEnabled(LocationManager.GPS_PROVIDER)) { gpsStatusTextView.setText(getString(R.string.status_gps_ready)); return true; } } } gpsStatusTextView.setText(getString(R.string.status_gps_no_support)); showDialog(NO_GPS_SUPPORT); Log.e(TAG, "Unable to get GPS PROVIDER"); // todo disable gps controls into Preferences return false; }
private void disableGpsProvider() { if (mLocationManager.getProvider(PROVIDER_NAME) != null) { mLocationManager.setTestProviderEnabled(PROVIDER_NAME, false); mLocationManager.clearTestProviderEnabled(PROVIDER_NAME); mLocationManager.clearTestProviderLocation(PROVIDER_NAME); mLocationManager.removeTestProvider(PROVIDER_NAME); } }
public void stop() { if(mVehicleManager != null) { mVehicleManager.removeListener(Latitude.class, this); mVehicleManager.removeListener(Longitude.class, this); mVehicleManager.removeListener(VehicleSpeed.class, this); } if(mLocationManager != null && mLocationManager.getProvider( VEHICLE_LOCATION_PROVIDER) != null) { mLocationManager.removeTestProvider(VEHICLE_LOCATION_PROVIDER); } }
LocationProvider gpsLocationProvider=locationManager.getProvider(LocationManager.GPS_PROVIDER); LocationProvider networkLocationProvider=locationManager.getProvider(LocationManager.NETWORK_PROVIDER);
if (locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) { locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, Locations.this, getMainLooper()); lastNetwork = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
myLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); System.out.println("location manager:"+myLocationManager.getAllProviders()); myLocationProvider = myLocationManager.getProvider("gps"); myNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); updatePreferences();
if (locationManager.getProvider(LocationManager.GPS_PROVIDER) != null) { if (FREQUENCY_GPS != Integer.parseInt(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS))) { locationManager.requestLocationUpdates( if (locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) { if (FREQUENCY_NETWORK != Integer.parseInt(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK))) { locationManager.requestLocationUpdates( if (locationManager.getProvider(LocationManager.PASSIVE_PROVIDER) != null) {
if (locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) { locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, Locations.this, getMainLooper()); lastNetwork = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
private void setupLocation() { final LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); try { // check if there is a gps final LocationProvider locProvider = locationManager.getProvider(GPS_PROVIDER); if (locProvider == null && !isFinishing()) { WiGLEToast.showOverActivity(this, R.string.app_name, getString(R.string.no_gps_device), Toast.LENGTH_LONG); } else if (!locationManager.isProviderEnabled(GPS_PROVIDER) && !isFinishing()) { // gps exists, but isn't on WiGLEToast.showOverActivity(this, R.string.app_name, getString(R.string.turn_on_gps), Toast.LENGTH_LONG); final Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); try { startActivity(myIntent); } catch (Exception ex) { error("exception trying to start location activity: " + ex, ex); } } } catch (final SecurityException ex) { info("Security exception in setupLocation: " + ex); return; } if (state.gpsListener == null) { // force a listener to be created final SharedPreferences prefs = getSharedPreferences(ListFragment.SHARED_PREFS, 0); internalHandleScanChange(prefs.getBoolean(ListFragment.PREF_SCAN_RUNNING, true)); } }
LocationProvider info = mgr.getProvider(s); StringBuilder builder = new StringBuilder(); builder.append("name: ").append(info.getName());
LocationProvider info = mgr.getProvider(s); StringBuilder builder = new StringBuilder(); builder.append("name: ").append(info.getName());
LocationProvider info = locationManager.getProvider(provider); output.append(info.toString() + "\n\n");
LocationProvider info = locationManager.getProvider(provider); output.append(info.toString() + "\n\n");