Best code examples for Android Location class (android.location.Location)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Location class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Location examples from Open Source projects
This code example shows how to use the following methods: getLatitude
157:	float diff = distFrom(result.getLatitude(), result.getLongitude(), loc.getLatitude(), loc.getLongitude()); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
63:	buf.append(String.valueOf(location.getLatitude())); 
-
65:	buf.append(String.valueOf(location.getLongitude())); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
193:	return new Point((int) (aLocation.getLongitude() * 1E6), 
194:	(int) (aLocation.getLatitude() * 1E6)); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getAltitude, getBearing, getLatitude, getLongitude, getSpeed
57:	locationChanged(location.getAltitude(),location.getLatitude(),location.getLongitude(),location.getSpeed(),location.getBearing()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
52:	return new LatLng(location.getLatitude(), location.getLongitude()); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getTime
56:	this.lastSeenTime = locationAtCreation == null ? 0 : locationAtCreation.getTime(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getLatitude
229:	final double latitude = Math.toRadians(mLocation.getLatitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getAccuracy, hasAccuracy
127:	return !location.hasAccuracy() || location.getAccuracy() < 600; 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getSpeed, hasSpeed
27:	if(_location.hasSpeed()) 
28:	_speed = _location.getSpeed(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
66:	buf.append(String.valueOf(location.getLatitude())); 
-
68:	buf.append(String.valueOf(location.getLongitude())); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
43:	BigDecimal longitude = (new BigDecimal(location.getLongitude())) 
-
46:	BigDecimal latitude = (new BigDecimal(location.getLatitude())) 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getAccuracy, getLatitude, getLongitude
130:	addParam("ll", location.getLatitude() + "," + location.getLongitude()); 
131:	addParam("lla", "" + (int) location.getAccuracy()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: distanceTo, getAccuracy, getLatitude, getLongitude, getProvider
98:	String.format("%s %f:%f (%f meters)", loc.getProvider(), 
99:	loc.getLatitude(), loc.getLongitude(), 
100:	loc.getAccuracy())); 
-
119:	Location older=(gps.getTime() < network.getTime() ? gps : network); 
-
124:	if (older.getAccuracy() <= newer.getAccuracy()) { 
-
140:	if (newer.distanceTo(older) < newer.getAccuracy()) { 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getSpeed
209:	return formatter_.speed(location.getSpeed()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAccuracy, setLatitude, setLongitude, setTime
78:	Location location = new Location(locationProvider); 
79:	location.setLatitude(latitude); 
80:	location.setLongitude(longitude); 
81:	location.setAccuracy(1); 
82:	location.setTime(System.currentTimeMillis()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getAccuracy, getAltitude, getLatitude, getLongitude, getSpeed
60:	packet = new GPSPacket(loc.getLatitude(), loc.getLongitude(), loc.getAltitude(), loc.getSpeed(), loc.getAccuracy()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getLatitude
33:	return location.getLatitude(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getTime
53:	if (location2.getTime() > location1.getTime()) 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
119:	String.format("%f:%f", lastKnownLocation.getLatitude(), 
120:	lastKnownLocation.getLongitude())); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
78:	new Wgs84GeoCoordinates(location.getLongitude(), location 
79:	.getLatitude()), distance); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getAccuracy, getLatitude, getLongitude
71:	mLatitude = loc.getLatitude(); 
72:	mLongitude = loc.getLongitude(); 
73:	mAccuracy = loc.getAccuracy(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getAccuracy, getAltitude, getLatitude, getLongitude, getSpeed
60:	public abstract class ClientListener extends Activity implements OnRecordPositionUpdateListener , LocationListener { 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getLatitude
229:	final double latitude = Math.toRadians(mLocation.getLatitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
52:	super.onLocationChanged(loc.getLongitude(), loc.getLatitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getAccuracy, getLatitude, getLongitude
68:	mGeoPoint = new GeoPoint((int) (location.getLatitude() * 1E6), 
69:	(int) (location.getLongitude() * 1E6)); 
70:	mAccuracy = location.getAccuracy(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
58:	lat = location.getLatitude(); 
59:	lon = location.getLongitude(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
69:	location.getLongitude(), location.getLatitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
107:	values.put(ImageColumns.LATITUDE, location.getLatitude()); 
108:	values.put(ImageColumns.LONGITUDE, location.getLongitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getTime
53:	return mLastLocation.getTime(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
94:	labelLongitude.setText("" + location.getLongitude()); 
95:	labelLatitude.setText("" + location.getLatitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
51:	assertEquals(1.0, l2.getLatitude()); 
52:	assertEquals(2.0, l2.getLongitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
118:	values.put(ImageColumns.LATITUDE, location.getLatitude()); 
119:	values.put(ImageColumns.LONGITUDE, location.getLongitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
47:	buf.append(String.valueOf(location.getLatitude())); 
-
49:	buf.append(String.valueOf(location.getLongitude())); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
61:	int lat = (int) (location.getLatitude()); 
62:	int lng = (int) (location.getLongitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
60:	return location == null ? new LatLng(LONDON_LAT, LONDON_LONG) : new LatLng(location.getLatitude(), location.getLongitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
48:	location = settings.getMapFactory().getGeoPointBase((int)(coordinatesIn.getLatitude() * 1e6), (int)(coordinatesIn.getLongitude() * 1e6)); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
51:	buffer.append(location.getLatitude()); 
-
53:	buffer.append(location.getLongitude()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
115:	int lat = (int) (location.getLatitude() * 1E6); 
116:	int lng = (int) (location.getLongitude() * 1E6); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
80:	return new GeoPoint((int)(aLoc.getLatitude() * 1E6), (int)(aLoc.getLongitude() * 1E6)); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
51:	double latitude = location.getLatitude(); 
52:	double longitude = location.getLongitude(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
36:	+ loc.getLatitude() + ", " 
37:	+ loc.getLongitude() + ")"); 
-
40:	+ loc.getLatitude() + ", " 
41:	+ loc.getLongitude() + ")"); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
21:	double lat = location.getLatitude(); 
22:	double lng = location.getLongitude(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
188:	location.getLatitude(), 
189:	location.getLongitude(), 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getLatitude, getLongitude
354:	addresses = geocoder.getFromLocation(loc.getLatitude(), loc.getLongitude(), 1); 
Full Snippet Info
9
CodeRank
Related Android Location Questions & Answers:
Other Android Location Examples
30:	    Criteria criteria = new Criteria();
31:	    provider = locationManager.getBestProvider(criteria, false);
32:	    Location location = locationManager.getLastKnownLocation(provider);
33:	
34:	    // Initialize the location fields
-
57:	
58:	  @Override
59:	  public void onLocationChanged(Location location) {
60:	    int lat = (int) (location.getLatitude());
61:	    int lng = (int) (location.getLongitude());

Read More

0:	public Location getLocation() {
1:			try {
2:				locationManager = (LocationManager) mContext
-
58:		}
59:		@Override
60:		public void onLocationChanged(Location location) {
61:		}
62:

Read More

26:		boolean canGetLocation = false;
27:	
28:		Location location = null; // location
29:		double latitude; // latitude
30:		double longitude; // longitude
-
44:		}
45:	
46:		public Location getLocation() {
47:			try {
48:				locationManager = (LocationManager) mContext
-
183:	
184:		@Override
185:		public void onLocationChanged(Location location) {
186:		}
187:

Read More

26:		boolean canGetLocation = false;
27:	
28:		Location location; // location
29:		double latitude; // latitude
30:		double longitude; // longitude
-
44:		}
45:	
46:		public Location getLocation() {
47:			try {
48:				locationManager = (LocationManager) mContext
-
179:	
180:		@Override
181:		public void onLocationChanged(Location location) {
182:		}
183:

Read More

See Code Examples for Android Location Methods: