List of usage examples for android.location Criteria ACCURACY_MEDIUM
int ACCURACY_MEDIUM
To view the source code for android.location Criteria ACCURACY_MEDIUM.
Click Source Link
From source file:Main.java
public static Criteria getGeoCriteria() { if (criteria == null) criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_MEDIUM); criteria.setPowerRequirement(Criteria.POWER_LOW); return criteria; }
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 .j a va 2 s . c om*/ 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:com.metinkale.prayerapp.vakit.AddCity.java
@SuppressWarnings("MissingPermission") public void checkLocation() { if (PermissionUtils.get(this).pLocation) { LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location loc = null;/*from w ww .java 2s . c om*/ List<String> providers = lm.getProviders(true); for (String provider : providers) { Location last = lm.getLastKnownLocation(provider); // one hour==1meter in accuracy if ((last != null) && ((loc == null) || ((last.getAccuracy() - (last.getTime() / (1000 * 60 * 60))) < (loc.getAccuracy() - (loc.getTime() / (1000 * 60 * 60)))))) { loc = last; } } if (loc != null) onLocationChanged(loc); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_MEDIUM); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(false); criteria.setSpeedRequired(false); String provider = lm.getBestProvider(criteria, true); if (provider != null) { lm.requestSingleUpdate(provider, this, null); } } else { PermissionUtils.get(this).needLocation(this); } }
From source file:cubes.compass.service.WeatherActivity.java
private void getWeatherFromCurrentLocation() { // system's LocationManager LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // medium accuracy for weather, good for 100 - 500 meters Criteria locationCriteria = new Criteria(); locationCriteria.setAccuracy(Criteria.ACCURACY_MEDIUM); String provider = locationManager.getBestProvider(locationCriteria, true); // single location update if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return;/* w ww . j av a 2s . c om*/ } locationManager.requestSingleUpdate(provider, this, null); }
From source file:ch.hesso.master.sweetcity.activity.map.MapActivity.java
public void showCurrentPosition() { if (map == null) return;//from w ww .j a va 2s . c o 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:com.marianhello.cordova.bgloc.LocationUpdateService.java
/** * Translates a number representing desired accuracy of GeoLocation system from set [0, 10, 100, 1000]. * 0: most aggressive, most accurate, worst battery drain * 1000: least aggressive, least accurate, best for battery. *///from w ww. jav a 2s. c o m private Integer translateDesiredAccuracy(Integer accuracy) { switch (accuracy) { case 1000: accuracy = Criteria.ACCURACY_LOW; break; case 100: accuracy = Criteria.ACCURACY_MEDIUM; break; case 10: accuracy = Criteria.ACCURACY_HIGH; break; case 0: accuracy = Criteria.ACCURACY_HIGH; break; default: accuracy = Criteria.ACCURACY_MEDIUM; } return accuracy; }