Android examples for Map:Last Location
get Last Known Location
//package com.java2s; import android.location.Location; import android.location.LocationManager; public class Main { public static final String FAKE_PROVIDER = "FAKE"; public static Location getLastKnownLocation( LocationManager locationManager) { Location result = new Location(FAKE_PROVIDER); if (locationManager == null) return result; Location lastKnownLocation = locationManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); if (lastKnownLocation == null) lastKnownLocation = locationManager .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (lastKnownLocation != null) { // never trust old accuracies if (lastKnownLocation.getAccuracy() < 50) { lastKnownLocation.setAccuracy(1000); }/*w ww . j a v a2 s .c om*/ result = lastKnownLocation; } return result; } }