List of usage examples for android.location Criteria Criteria
public Criteria()
From source file:net.frakbot.FWeather.util.LocationHelper.java
/** * Returns the default criteria set for the LocationManager. * @return the default Criteria// w w w .j a va2s .c om */ 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:edu.mit.mobile.android.locast.ver2.casts.LocatableListWithMap.java
/** * Gets the last-known location and updates with that. *//*w w w. j a va 2s.co m*/ private void updateLocation() { final LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); final String provider = lm.getBestProvider(new Criteria(), true); if (provider == null) { Toast.makeText(this, getString(R.string.error_no_providers), Toast.LENGTH_LONG).show(); finish(); return; } final Location loc = lm.getLastKnownLocation(provider); if (loc != null) { updateLocation(loc); } else { Toast.makeText(this, R.string.notice_finding_your_location, Toast.LENGTH_LONG).show(); setRefreshing(true); mMapView.setVisibility(View.VISIBLE); // show the map, even without location being found } mLastLocation = loc; }
From source file:com.brejza.matt.habmodem.Dsp_service.java
private void enableLocation() { //my location part Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); String bestProvider = this.locationManager.getBestProvider(criteria, true); if (bestProvider == null) return;//from ww w . j a va2 s . c o m System.out.println("STARTING GPS WITH: " + bestProvider); logEvent("Starting Location with: " + bestProvider, true); this.locationManager.requestLocationUpdates(bestProvider, 2000, 0, this.loc_han); }
From source file:com.nearnotes.NoteLocation.java
@Override public void onProviderEnabled(String provider) { Toast.makeText(getActivity(), "Enabled new provider " + provider, Toast.LENGTH_SHORT).show(); Criteria criteria = new Criteria(); provider = mLocationManager.getBestProvider(criteria, true); mLocationManager.requestLocationUpdates(provider, 0, 0, this); }
From source file:com.example.testapplication.DialogLocation.java
@Override public void onProviderEnabled(String provider) { Toast.makeText(getActivity(), "Enabled new provider " + provider, Toast.LENGTH_SHORT).show(); Criteria criteria = new Criteria(); provider = mLocationManager.getBestProvider(criteria, true); mLocationManager.requestLocationUpdates(provider, 0, 0, this); }
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
private void getBestProvider(LocationManager lm) { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAccuracy(Criteria.ACCURACY_FINE); String bestProvider = lm.getBestProvider(criteria, true); if (bestProvider != null) { lm.requestLocationUpdates(bestProvider, 0, 0, this); location = lm.getLastKnownLocation(bestProvider); for (InputLayout input : locationInputs) { input.setLocation(location); }/*w w w .j a va 2 s. c o m*/ } else { new AlertDialog.Builder(this).setMessage(R.string.need_location).setCancelable(true) .setPositiveButton(R.string.enable_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { launchGpsSettings(); dialog.dismiss(); } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).create().show(); } }
From source file:com.nearnotes.NoteLocation.java
@Override public void onProviderDisabled(String provider) { Toast.makeText(getActivity(), "Disabled provider " + provider, Toast.LENGTH_SHORT).show(); Criteria criteria = new Criteria(); provider = mLocationManager.getBestProvider(criteria, true); mLocationManager.requestLocationUpdates(provider, 0, 0, this); }
From source file:se.team05.activity.RouteActivity.java
/** * Sets up the location manager, location lsitener and some criteria that * ask for the gps provider (fine). Then add overlay for my location and the * trace of the user's route.//from w w w. j a v a 2s . c om */ private void setupMyLocationAndListener() { locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mapLocationListener = new MapLocationListener(this, route.isNewRoute(), route.getCheckPoints()); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mapLocationListener); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setCostAllowed(false); String providerName = locationManager.getBestProvider(criteria, true); if (providerName != null) { Log.d(TAG, getString(R.string.provider_) + providerName); } myLocationOverlay = new MyLocationOverlay(this, mapView); overlays.add(myLocationOverlay); RouteOverlay userRouteOverlay = new RouteOverlay(route.getGeoPoints(), USER_ROUTE_COLOR); overlays.add(userRouteOverlay); }
From source file:com.example.testapplication.DialogLocation.java
@Override public void onProviderDisabled(String provider) { Toast.makeText(getActivity(), "Disabled provider " + provider, Toast.LENGTH_SHORT).show(); Criteria criteria = new Criteria(); provider = mLocationManager.getBestProvider(criteria, true); mLocationManager.requestLocationUpdates(provider, 0, 0, this); }
From source file:jp.co.tweetmap.Fragment0.java
/** * This is where we can add markers or lines, add listeners or move the camera. In this case, we * just add a marker near Africa.// w w w .j a v a 2 s. co m * <p/> * This should only be called once and when we are sure that {@link #mMap} is not null. */ private void setUpMap() { if (LogUtil.isDebug()) Log.e(TAG, "### mapInit() ###"); // LocationManager LocationManager locationManager = (LocationManager) this.getActivity().getApplicationContext() .getSystemService(Context.LOCATION_SERVICE); double latitude = MapUtil.TOKYO_STATION_LATITUDE; double longitude = MapUtil.TOKYO_STATION_LONGITUDE; if (null != locationManager) { String bestProv = locationManager.getBestProvider(new Criteria(), true); // Get location information from GPS Location myLocate = locationManager.getLastKnownLocation(bestProv); if (null == myLocate) { myLocate = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); } if (null == myLocate) { myLocate = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } if (null != myLocate) { latitude = myLocate.getLatitude(); longitude = myLocate.getLongitude(); } } CameraPosition camerapos = new CameraPosition.Builder().target(new LatLng(latitude, longitude)).zoom(15.0f) .build(); // Move camera position mMap.moveCamera(CameraUpdateFactory.newCameraPosition(camerapos)); // Set current position mCenterPosition = camerapos; getNearestStation(); }