List of usage examples for android.location Criteria ACCURACY_FINE
int ACCURACY_FINE
To view the source code for android.location Criteria ACCURACY_FINE.
Click Source Link
From source file:Main.java
public static String getBestProvider(LocationManager locationManager) throws IllegalArgumentException { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.NO_REQUIREMENT); return locationManager.getBestProvider(criteria, true); }
From source file:Main.java
public static String getGpsString(Context context) { if (context == null) { return null; }/*from w ww .j av a 2 s. com*/ String gps = null; Location location = null; Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(true); LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); String provider = locationManager.getBestProvider(criteria, true); if (provider != null) { location = locationManager.getLastKnownLocation(provider); } if (location != null) { double longtitude = location.getLongitude(); double latitude = location.getLatitude(); gps = "Lon:" + longtitude + "; Lat:" + latitude; } if (gps == null) { gps = "Lon:0; Lat:0"; } return gps; }
From source file:com.appdynamics.demo.gasp.utils.LocationServices.java
/** * Set Location Services and get current location *///from w w w . j ava 2s .c o 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.dwdesign.tweetings.activity.NearbyMapViewerActivity.java
protected void getLocationAndCenterMap() { LocationManager mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); final Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); final String provider = mLocationManager.getBestProvider(criteria, true); Location mRecentLocation = null; if (provider != null) { mRecentLocation = mLocationManager.getLastKnownLocation(provider); } else {/* www. j a va2s . c om*/ Toast.makeText(this, R.string.cannot_get_location, Toast.LENGTH_SHORT).show(); } if (mRecentLocation != null && isNativeMapSupported()) { NativeNearbyMapFragment aFragment = (NativeNearbyMapFragment) mFragment; aFragment.setCenter(mRecentLocation); } }
From source file:com.dwdesign.tweetings.activity.MapViewerActivity.java
protected void getLocationAndCenterMap() { LocationManager mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); final Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); final String provider = mLocationManager.getBestProvider(criteria, true); Location mRecentLocation = null; if (provider != null) { mRecentLocation = mLocationManager.getLastKnownLocation(provider); } else {// w w w . j ava2s . c o m Toast.makeText(this, R.string.cannot_get_location, Toast.LENGTH_SHORT).show(); } if (mRecentLocation != null && isNativeMapSupported()) { NativeMapFragment aFragment = (NativeMapFragment) mFragment; aFragment.setCenter(mRecentLocation); } }
From source file:net.quranquiz.ui.QQMap.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map);/*from w ww . ja v a2 s . c o m*/ map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); map.setOnMarkerClickListener((OnMarkerClickListener) this); cairo = new LatLng(30.1, 31.45); LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); boolean enabledGPS = service.isProviderEnabled(LocationManager.GPS_PROVIDER); // Check if enabled and if not send user to the GSP settings // Better solution would be to display a dialog and suggesting to // go to the settings if (!enabledGPS) { Toast.makeText(this, "GPS signal not found", Toast.LENGTH_LONG).show(); startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); // Initialize the location fields if (location != null) { Toast.makeText(this, "Selected Provider " + provider, Toast.LENGTH_SHORT).show(); meMarker = map.addMarker( new MarkerOptions().position(cairo).title("That's Me").snippet("a normal QuranQuiz Node!") .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher))); map.moveCamera(CameraUpdateFactory.newLatLngZoom(cairo, 12.0f)); onLocationChanged(location); } else { //do something } }
From source file:com.findcab.driver.activity.Signup.java
private void initView() { context = this; back = (Button) findViewById(R.id.back); back.setOnClickListener(this); start = (Button) findViewById(R.id.start); start.setOnClickListener(this); edit_name = (EditText) findViewById(R.id.name); edit_mobile = (EditText) findViewById(R.id.mobile); edit_password = (EditText) findViewById(R.id.password); checkBox = (CheckBox) findViewById(R.id.checkBox); item = (TextView) findViewById(R.id.item); item.setOnClickListener(this); if (initGPS()) { LocationManager locationManager; String serviceName = Context.LOCATION_SERVICE; locationManager = (LocationManager) this.getSystemService(serviceName); // ?/*from w w w.j a v a 2 s.c o m*/ Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = locationManager.getBestProvider(criteria, true); location = locationManager.getLastKnownLocation(provider); if (location != null) { lat = location.getLatitude(); lng = location.getLongitude(); } } }
From source file:com.example.androidmapsv2.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getVistas();/*from ww w . j a va 2 s .co m*/ // Establezco los criterios para la localizacin. criteriosLocalizacion = new Criteria(); criteriosLocalizacion.setAccuracy(Criteria.ACCURACY_FINE); // Creo un localizador para que me informe del cambio de posicin. localizador = (LocationManager) getSystemService(LOCATION_SERVICE); }
From source file:it.ms.theing.loquitur.functions.LocationInterface.java
private Location getLocation() { done = true;/*from w ww. jav a 2 s.c om*/ long timeInMillis = Calendar.getInstance().getTimeInMillis(); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); String fine = locationManager.getBestProvider(criteria, true); if (fine == null) return null; Location location = locationManager.getLastKnownLocation(fine); if (location != null) { if (timeInMillis - location.getTime() < TIMEVAL) { return location; } } criteria.setAccuracy(Criteria.ACCURACY_COARSE); String coarse = locationManager.getBestProvider(criteria, true); if (!(fine.equals(coarse))) { location = locationManager.getLastKnownLocation(fine); if (location != null) { if (timeInMillis - location.getTime() < TIMEVAL) { return location; } } } timeout.postDelayed(tout, TIMEOUT); // At most 1 minute //locationManager.requestSingleUpdate(fine, ll, Looper.myLooper()); locationManager.requestSingleUpdate(fine, ll, null); done = false; return null; }
From source file:com.commonsware.android.mapsv2.location.MainActivity.java
@SuppressLint("MissingPermission") @Override/* www . j a v a 2s. c om*/ public void onMapReady(final GoogleMap map) { this.map = map; if (needsInit) { CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(40.76793169992044, -73.98180484771729)); CameraUpdate zoom = CameraUpdateFactory.zoomTo(15); map.moveCamera(center); map.animateCamera(zoom); } addMarker(map, 40.748963847316034, -73.96807193756104, R.string.un, R.string.united_nations); addMarker(map, 40.76866299974387, -73.98268461227417, R.string.lincoln_center, R.string.lincoln_center_snippet); addMarker(map, 40.765136435316755, -73.97989511489868, R.string.carnegie_hall, R.string.practice_x3); addMarker(map, 40.70686417491799, -74.01572942733765, R.string.downtown_club, R.string.heisman_trophy); map.setInfoWindowAdapter(new PopupAdapter(getLayoutInflater())); map.setOnInfoWindowClickListener(this); map.setMyLocationEnabled(true); locMgr = (LocationManager) getSystemService(LOCATION_SERVICE); crit.setAccuracy(Criteria.ACCURACY_FINE); follow(); }