List of usage examples for android.location Criteria setSpeedRequired
public void setSpeedRequired(boolean speedRequired)
From source file:ch.hesso.master.sweetcity.activity.map.MapActivity.java
public void showCurrentPosition() { if (map == null) return;/* w ww .j a 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 w ww . ja v a 2s . c o 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:com.zainsoft.ramzantimetable.QiblaActivity.java
private void registerForGPS() { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false);/*from w ww .j a va2 s . co m*/ criteria.setSpeedRequired(false); criteria.setCostAllowed(true); LocationManager locationManager = ((LocationManager) getSystemService(Context.LOCATION_SERVICE)); String provider = locationManager.getBestProvider(criteria, true); if (provider != null) { locationManager.requestLocationUpdates(provider, MIN_LOCATION_TIME, MIN_LOCATION_DISTANCE, qiblaManager); } locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_LOCATION_TIME, MIN_LOCATION_DISTANCE, qiblaManager); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_LOCATION_TIME, MIN_LOCATION_DISTANCE, qiblaManager); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location == null) { location = ((LocationManager) getSystemService(Context.LOCATION_SERVICE)) .getLastKnownLocation(LocationManager.GPS_PROVIDER); } if (location != null) { qiblaManager.onLocationChanged(location); } }
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 w w w.j a v a 2 s.c o m 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(); }
From source file:com.google.ytd.SubmitActivity.java
private void getVideoLocation() { this.locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_HIGH); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false);/*from w ww . j a v a2 s . c om*/ criteria.setSpeedRequired(false); criteria.setCostAllowed(true); String provider = locationManager.getBestProvider(criteria, true); this.locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { if (location != null) { SubmitActivity.this.videoLocation = location; double lat = location.getLatitude(); double lng = location.getLongitude(); Log.d(LOG_TAG, "lat=" + lat); Log.d(LOG_TAG, "lng=" + lng); TextView locationText = (TextView) findViewById(R.id.locationLabel); locationText.setText("Geo Location: " + String.format("lat=%.2f lng=%.2f", lat, lng)); locationManager.removeUpdates(this); } else { Log.d(LOG_TAG, "location is null"); } } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } }; if (provider != null) { locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); } }
From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionListActivity.java
/** * Get provider name.// w ww . ja v a 2 s. c o m * @return Name of best suiting provider. * */ String getProviderName() { LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setPowerRequirement(Criteria.POWER_LOW); // Chose your desired power consumption level. criteria.setAccuracy(Criteria.ACCURACY_FINE); // Choose your accuracy requirement. criteria.setSpeedRequired(false); // Chose if speed for first location fix is required. criteria.setAltitudeRequired(false); // Choose if you use altitude. criteria.setBearingRequired(false); // Choose if you use bearing. criteria.setCostAllowed(false); // Choose if this provider can waste money :-) // Provide your criteria and flag enabledOnly that tells // LocationManager only to return active providers. return locationManager.getBestProvider(criteria, true); }
From source file:com.rareventure.gps2.reviewer.map.OsmMapGpsTrailerReviewerMapActivity.java
public void setupLocationUpdates(GpsLocationOverlay gpsLocationOverlay) { //the user may have disabled us from reading location data if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { Criteria criteria = new Criteria(); criteria.setSpeedRequired(false); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(false);//from w w w . ja v a 2 s .c om String locationProviderName = locationManager.getBestProvider(criteria, true); locationManager.requestLocationUpdates(locationProviderName, 0, 0, gpsLocationOverlay, getMainLooper()); } }
From source file:com.BeatYourRecord.SubmitActivity.java
private void getVideoLocation() { this.locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_HIGH); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false);//from ww w . j a va 2 s. c o m criteria.setSpeedRequired(false); criteria.setCostAllowed(true); String provider = locationManager.getBestProvider(criteria, true); this.locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { if (location != null) { SubmitActivity.this.videoLocation = location; lat = location.getLatitude(); lng = location.getLongitude(); Log.d(LOG_TAG, "lat=" + lat); Log.d(LOG_TAG, "lng=" + lng); TextView locationText = (TextView) findViewById(R.id.locationLabel); locationText.setText("Geo Location: " + String.format("lat=%.2f lng=%.2f", lat, lng)); locationManager.removeUpdates(this); } else { Log.d(LOG_TAG, "location is null"); } } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } }; if (provider != null) { locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); } }