我想根据我的设备当前位置获取国家代码。我已经使用了LocationListener
如下:Android获取国家代码的位置
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
makeUseOfNewLocation(location);
}
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0, locationListener);
...但它需要很长时间才能返回位置。
如何更快地获得国家/地区代码?
请提供到目前为止你已经尝试过的代码.... – Gunaseelan
的LocationManager =
您也可以使用最后已知位置获得您的位置更快解决问题 \t \t \t \t(LocationManager)getSystemService(Context.LOCATION_SERVICE); \t \t LocationListener的新= LocationListener的(){ \t \t \t公共无效onLocationChanged(地点位置){ \t \t \t \t makeUseOfNewLocation(位置); \t \t \t} –
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener); –