读书人

取得坐标

发布时间: 2012-09-21 15:47:26 作者: rapoo

获得坐标

public static Location getLocation(Context ctx) {?
? ? LocationManager lm = (LocationManager) ctx?
? ? ? ? ? ? .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;?
? ? }?
? ? return l;?
}?

读书人网 >移动开发

热点推荐