Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Location getLatestLocation(final Context context) {
- LocationManager manager = (LocationManager) context
- .getSystemService(LOCATION_SERVICE);
- Criteria criteria = new Criteria();
- criteria.setAccuracy(ACCURACY_FINE);
- String provider = manager.getBestProvider(criteria, true);
- Location bestLocation;
- if (provider != null)
- bestLocation = manager.getLastKnownLocation(provider);
- else
- bestLocation = null;
- Location latestLocation = getLatest(bestLocation,
- manager.getLastKnownLocation(GPS_PROVIDER));
- latestLocation = getLatest(latestLocation,
- manager.getLastKnownLocation(NETWORK_PROVIDER));
- latestLocation = getLatest(latestLocation,
- manager.getLastKnownLocation(PASSIVE_PROVIDER));
- return latestLocation;
- }
Add Comment
Please, Sign In to add comment