Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); onLocationChanged(location); } else { latituteField.setText("Location not available"); longitudeField.setText("Location not available"); protected void onResume() { super.onResume(); locationManager.requestLocationUpdates(provider, 400, 1, this); double lng = location.getLongitude(); Geocoder geoCoder = new Geocoder(this, Locale.getDefault()); StringBuilder builder = new StringBuilder(); try { latituteField.setText(String.valueOf(lat)); longitudeField.setText(String.valueOf(lng)); addressField.setText(fnialAddress); //This will display the final address.
Criteria myCriteria = new Criteria(); myCriteria.setAccuracy(Criteria.ACCURACY_HIGH); myCriteria.setPowerRequirement(Criteria.POWER_LOW); // let Android select the right location provider for you String myProvider = locationManager.getBestProvider(myCriteria, true); // finally require updates at -at least- the desired rate long minTimeMillis = 600000; // 600,000 milliseconds make 10 minutes locationManager.requestLocationUpdates(myProvider,minTimeMillis,0,locationListener);
int parentId = 100; int level = 5; Criteria c = new Criteria().andOperator(Criteria.where("treePath").is(parentId), Criteria.where("treePath").size(level)); System.out.println(c.getCriteriaObject());
Button gpsButton = (Button)this.findViewById(R.id.buttonGPSLocation); gpsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Start loction service LocationManager locationManager = (LocationManager)[OUTERCLASS].this.getSystemService(Context.LOCATION_SERVICE); Criteria locationCritera = new Criteria(); locationCritera.setAccuracy(Criteria.ACCURACY_COARSE); locationCritera.setAltitudeRequired(false); locationCritera.setBearingRequired(false); locationCritera.setCostAllowed(true); locationCritera.setPowerRequirement(Criteria.NO_REQUIREMENT); String providerName = locationManager.getBestProvider(locationCritera, true); if (providerName != null && locationManager.isProviderEnabled(providerName)) { // Provider is enabled locationManager.requestLocationUpdates(providerName, 20000, 100, [OUTERCLASS].this.locationListener); } else { // Provider not enabled, prompt user to enable it Toast.makeText([OUTERCLASS].this, R.string.please_turn_on_gps, Toast.LENGTH_LONG).show(); Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); [OUTERCLASS].this.startActivity(myIntent); } } });
Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); locationManager.requestLocationUpdates(provider, 20000, 1, this); onLocationChanged(location); else Toast.makeText(getBaseContext(), "Location can't be retrieved", Toast.LENGTH_SHORT).show(); tvLongitude.setText("Longitude:" + location.getLongitude()); tvLatitude.setText("Latitude:" + location.getLatitude() );
Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); locationManager.requestLocationUpdates(provider, 20000, 1, this); onLocationChanged(location); else Toast.makeText(getBaseContext(), "Location can't be retrieved", Toast.LENGTH_SHORT).show(); tvLongitude.setText("Longitude:" + location.getLongitude()); tvLatitude.setText("Latitude:" + location.getLatitude() ); geocoder = new Geocoder(this, Locale.getDefault()); addresses = geocoder.getFromLocation(MyLat, MyLong, 1); String cityName = addresses.get(0).getAddressLine(0);
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); String provider = locationManager.getBestProvider(new Criteria(), true); Location locations = locationManager.getLastKnownLocation(provider); List<String> providerList = locationManager.getAllProviders(); if(null!=locations && null!=providerList && providerList.size()>0){ double longitude = locations.getLongitude(); double latitude = locations.getLatitude(); Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); try { List<Address> listAddresses = geocoder.getFromLocation(latitude, longitude, 1); if(null!=listAddresses&&listAddresses.size()>0){ String _Location = listAddresses.get(0).getAddressLine(0); } } catch (IOException e) { e.printStackTrace(); } }
Criteria criteria = new Criteria(); String provider = locationManager.getBestProvider(criteria, true); final Location location = locationManager .getLastKnownLocation(provider); latitude = location.getLatitude(); longitude = location.getLongitude(); Locale.getDefault()); try { List<Address> addresses = geocoder.getFromLocation(latitude,
Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_LOW); String provider = mLocManager.getBestProvider(criteria, true); Location location = mLocManager.getLastKnownLocation(provider); mLocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ); } else { setLat(location); latituteField.setText(String.valueOf(location.getLatitude())); public void onLocationChanged(Location location) { if (location != null) { setLat(location); mLocManager.removeUpdates(this);
.isProviderEnabled(LocationManager.GPS_PROVIDER); Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria,false); Location location = locationManager.getLastKnownLocation(provider); latituteField.setText("Location not available"); longitudeField.setText("Location not available");
tv = (TextView) findViewById(R.id.tv1); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_LOW); String locationprovider = mLocationManager.getBestProvider(criteria, true); mLocationManager.requestLocationUpdates(locationprovider, 5000, (float) 2.0, this); public void onLocationChanged(Location location) { mLocation = location; showupdate(); tv.setText("Last location lat:" + mLocation.getLatitude() + " long:" + mLocation.getLongitude());
Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); //Try this instead criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); provider = mlocManager.getBestProvider(criteria, true); loc = mlocManager.getLastKnownLocation(provider); lat = loc.getLatitude(); lon = loc.getLongitude(); locText.setText(lat + " " + lon); public void onClick(View v) { if (provider != null) { loc = mlocManager.getLastKnownLocation(provider); lat = loc.getLatitude(); lon = loc.getLongitude(); locText.setText(lat + " " + lon);
public void getCord() { final TextView text = (TextView) findViewById(R.id.textView); LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); if(service != null){ if (!service.isProviderEnabled(LocationManager.GPS_PROVIDER)){ Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } else{ // Get the location manager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Define the criteria how to select the locatioin provider -> use // defaultazz Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); //int lng = (int) (location.getLongitude()); text.setText("" +location.getLatitude()); } } }
Criteria criteria = new Criteria(); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); Log.d("Lat-Lng", location.getLatitude()+","+location.getLongitude()); getUserGeoInfo(location.getLatitude(), location.getLongitude()); Geocoder geoCoder = new Geocoder(context, Locale.getDefault()); if (Geocoder.isPresent()) { List<Address> addresses = geoCoder.getFromLocation(lat, lon, 1);
try { LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); String provider = locationManager.getBestProvider(criteria,true); Location curLocation = locationManager.getLastKnownLocation(provider); GeoPoint curGeoPoint = new GeoPoint((int)(curLocation.getLatitude() * 1e6), (int)(curLocation.getLongitude()*1e6)); return curGeoPoint; } catch (NullPointerException e) { Geocoder geocoder = new Geocoder(context, Locale.getDefault()); List<Address> addresses = null; try {
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false)); if (location != null) { map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 13)); CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(location.getLatitude(), location.getLongitude())) // Sets the center of the map to location user .zoom(17) // Sets the zoom .bearing(90) // Sets the orientation of the camera to east .tilt(40) // Sets the tilt of the camera to 30 degrees .build(); // Creates a CameraPosition from the builder map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); }
Criteria criteria = new Criteria(); provider = lm.getBestProvider(criteria, false); Location location = lm.getLastKnownLocation(provider); onLocationChanged(location); protected void onResume() { super.onResume(); lm.requestLocationUpdates(provider, 1000, 10, this);
gps_enabled = (Boolean) myLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); myLocationManager.requestLocationUpdates("network", 0, 0, networkLocationListener); myLocationManager.requestLocationUpdates("gps", 0, 0, gpsLocationListener); myLocationManager.addGpsStatusListener(gpsStatusListener); LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(true); String strLocationProvider = lm.getBestProvider(criteria, true);
private final Criteria criteria = new Criteria(); private String bestAvailableProvider; criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAltitudeRequired(true); criteria.setBearingRequired(true); criteria.setSpeedRequired(true); criteria.setCostAllowed(true); bestAvailableProvider = locationManager.getBestProvider(criteria, true); locationManager.requestLocationUpdates(bestAvailableProvider, minTime, minDistance, this); } else { public void deactivate() { locationManager.removeUpdates(this); mMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude())));
setContentView(R.layout.activity_main); LocationManager service=(LocationManager)getSystemService(LOCATION_SERVICE); boolean enableGPS= service.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean enableWifi=service.isProviderEnabled(LocationManager.NETWORK_PROVIDER); Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); initilizeMap(); } catch (Exception e) {