首页 > 代码库 > Android获取手机位置(LocationManager)

Android获取手机位置(LocationManager)

LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
List<String> providers = lm.getProviders(true);
Location l = null;
for (int i=providers.size()-1; i>=0; i--) {
    l = lm.getLastKnownLocation(providers.get(i));
    if (l != null) break;
}

Android获取手机位置(LocationManager)