List of usage examples for android.location Criteria setSpeedAccuracy
public void setSpeedAccuracy(int accuracy)
From source file:ch.hesso.master.sweetcity.activity.map.MapActivity.java
public void showCurrentPosition() { if (map == null) return;//from w w w . ja v a 2 s . co m // Enabling MyLocation Layer of Google Map map.setMyLocationEnabled(true); Criteria lightCriteria = new Criteria(); lightCriteria.setAccuracy(Criteria.ACCURACY_COARSE); lightCriteria.setAltitudeRequired(false); lightCriteria.setBearingRequired(false); lightCriteria.setCostAllowed(false); lightCriteria.setHorizontalAccuracy(Criteria.ACCURACY_MEDIUM); lightCriteria.setPowerRequirement(Criteria.NO_REQUIREMENT); lightCriteria.setSpeedAccuracy(Criteria.NO_REQUIREMENT); lightCriteria.setSpeedRequired(false); listener = new MapLocationListener(map); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.requestSingleUpdate(lightCriteria, listener, null); locationProvider = locationManager.getBestProvider(new Criteria(), true); Location location = locationManager.getLastKnownLocation(locationProvider); if (location != null) { listener.onLocationChanged(location); map.animateCamera(CameraUpdateFactory.zoomTo(15)); } }
From source file:ch.hesso.master.sweetcity.activity.report.ReportActivity.java
void updateCurrentLocation() { if (this.locationListener == null) this.locationListener = new LocationListener() { @Override/*from ww w. ja v a2 s. co m*/ public void onLocationChanged(Location location) { ReportActivity.this.currentLocation = location; } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } }; Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(false); criteria.setHorizontalAccuracy(Criteria.ACCURACY_MEDIUM); criteria.setPowerRequirement(Criteria.NO_REQUIREMENT); criteria.setSpeedAccuracy(Criteria.NO_REQUIREMENT); criteria.setSpeedRequired(false); LocationManager locationManager = (LocationManager) ReportActivity.this.getSystemService(LOCATION_SERVICE); locationManager.requestSingleUpdate(criteria, this.locationListener, null); }
From source file:name.gumartinm.weather.information.activity.MapActivity.java
public void onClickGetLocation(final View v) { // TODO: Somehow I should show a progress dialog. // If Google Play Services is available if (this.mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { // TODO: Hopefully there will be results even if location did not change... final Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingAccuracy(Criteria.NO_REQUIREMENT); criteria.setBearingRequired(false); criteria.setCostAllowed(false);//from www . j a va2 s .com criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH); criteria.setPowerRequirement(Criteria.POWER_MEDIUM); criteria.setSpeedAccuracy(Criteria.NO_REQUIREMENT); criteria.setSpeedRequired(false); criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH); this.mLocationManager.requestSingleUpdate(criteria, this, null); } else { Toast.makeText(this, this.getString(R.string.weather_map_not_enabled_location), Toast.LENGTH_LONG) .show(); } // Trying to use the synchronous calls. Problems: mGoogleApiClient read/store from different threads. // new GetLocationTask(this).execute(); }