我想根據我的設備當前位置獲取國家代碼。我已經使用了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); –