List of usage examples for android.location Criteria setSpeedRequired
public void setSpeedRequired(boolean speedRequired)
From source file:Main.java
/** * this criteria will settle for less accuracy, high power, and cost *//*from w w w . ja v a 2 s. c om*/ public static Criteria createCoarseCriteria() { Criteria c = new Criteria(); c.setAccuracy(Criteria.ACCURACY_COARSE); c.setAltitudeRequired(false); c.setBearingRequired(false); c.setSpeedRequired(false); c.setCostAllowed(true); c.setPowerRequirement(Criteria.POWER_HIGH); return c; }
From source file:com.appdynamics.demo.gasp.utils.LocationServices.java
/** * Set Location Services and get current location *//*ww w . j a v a2 s . co m*/ public static Location getLocation(Context context) { Location location = null; try { String svcName = Context.LOCATION_SERVICE; LocationManager locationManager = (LocationManager) context.getSystemService(svcName); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setSpeedRequired(false); criteria.setCostAllowed(true); String provider = locationManager.getBestProvider(criteria, true); location = locationManager.getLastKnownLocation(provider); Log.i(TAG, "Current Latitude = " + location.getLatitude()); Log.i(TAG, "Current Longitude = " + location.getLongitude()); } catch (Exception e) { e.printStackTrace(); } return location; }
From source file:com.ushahidi.android.app.util.Util.java
/** this criteria needs high accuracy, high power, and cost */ public static Criteria createFineCriteria() { Criteria c = new Criteria(); c.setAccuracy(Criteria.ACCURACY_FINE); c.setAltitudeRequired(false);/*from www . j ava 2 s . c o m*/ c.setBearingRequired(false); c.setSpeedRequired(false); c.setCostAllowed(true); c.setPowerRequirement(Criteria.POWER_HIGH); return c; }
From source file:com.airbop.library.simple.CommonUtilities.java
/** * Simple helper that gets the location criteria that we want. * @return//ww w . j av a 2 s. com */ public static Criteria getCriteria() { if (true) { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setSpeedRequired(false); criteria.setCostAllowed(true); return criteria; } return null; }
From source file:net.frakbot.FWeather.util.LocationHelper.java
/** * Returns the default criteria set for the LocationManager. * @return the default Criteria// w ww . jav a 2s . c o m */ private static Criteria getDefaultCriteria() { Criteria criteria = new Criteria(); criteria.setCostAllowed(false); criteria.setHorizontalAccuracy(Criteria.ACCURACY_LOW); criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT); criteria.setSpeedRequired(false); criteria.setPowerRequirement(Criteria.POWER_LOW); return criteria; }
From source file:com.rareventure.android.GpsReader.java
public void turnOn() { synchronized (lock) { // Log.d(GpsTrailerService.TAG,"Turning on gps"); if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { GTG.alert(GTGEvent.ERROR_GPS_DISABLED); return; }/*from w ww.ja va 2 s . c o m*/ if (ActivityCompat.checkSelfPermission(this.ctx, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { GTG.alert(GTGEvent.ERROR_GPS_NO_PERMISSION); // Log.d(GpsTrailerService.TAG,"Failed no permission"); return; } if (gpsOn) { // Log.d(GpsTrailerService.TAG,"Gps already on"); return; //already on } gpsOn = true; // Log.d(GpsTrailerService.TAG,"Really turning on"); Criteria criteria = new Criteria(); criteria.setSpeedRequired(false); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(false); String providerName = lm.getBestProvider(criteria, true); lm.requestLocationUpdates(providerName, prefs.gpsRecurringTimeMs, 0, locationListener, looper); } }
From source file:com.cloudbees.gasp.activity.GaspLocationsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_locations); GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); LocationManager locationManager;/*from w ww . ja va 2 s . c om*/ String svcName = Context.LOCATION_SERVICE; locationManager = (LocationManager) getSystemService(svcName); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setSpeedRequired(false); criteria.setCostAllowed(true); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); Log.i(TAG, "CURRENT LOCATION"); Log.i(TAG, "Latitude = " + location.getLatitude()); Log.i(TAG, "Longitude = " + location.getLongitude()); if (location != null) { double latitude = location.getLatitude(); double longitude = location.getLongitude(); Geocoder gc = new Geocoder(this, Locale.getDefault()); if (!Geocoder.isPresent()) Log.i(TAG, "No geocoder available"); else { try { List<Address> addresses = gc.getFromLocation(latitude, longitude, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append(" "); sb.append(address.getLocality()).append(""); sb.append(address.getPostalCode()).append(" "); sb.append(address.getCountryName()); } Log.i(TAG, "Address: " + sb.toString()); } catch (IOException e) { Log.d(TAG, "IOException getting address from geocoder", e); } } } map.setMyLocationEnabled(true); LatLng myLocation = new LatLng(location.getLatitude(), location.getLongitude()); CameraPosition cameraPosition = new CameraPosition.Builder().target(myLocation).zoom(16).bearing(0).tilt(0) .build(); map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); new LocationMapper().execute(); }
From source file:de.avanux.android.livetracker2.LocationTracker.java
public String getGpsProvider() { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false);//from w w w. j a v a 2 s. c om criteria.setCostAllowed(false); // criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setSpeedRequired(true); return getLocationManager().getBestProvider(criteria, true); }
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 ww w . jav a 2 s .c o m*/ 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:com.quantcast.measurement.service.QCLocation.java
void setupLocManager(Context appContext) { if (appContext == null) return;// w w w . j a v a 2 s . c o m _locManager = (LocationManager) appContext.getSystemService(Context.LOCATION_SERVICE); if (_locManager != null) { //specifically set our Criteria. All we need is a general location Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(false); criteria.setPowerRequirement(Criteria.NO_REQUIREMENT); criteria.setSpeedRequired(false); _myProvider = _locManager.getBestProvider(criteria, true); _geocoder = new Geocoder(appContext); } QCLog.i(TAG, "Setting location provider " + _myProvider); }