嘿,我想要得到當前位置的名稱。我沒有編碼獲得當前位置(經緯度,郎)我怎麼能顯示相對地名android獲取當前位置名稱
(IE)13.006389 - 80.2575:阿達亞,晨奈,印度
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
public void onStatusChanged(String provider, int status, Bundle extras) {
// called when the location provider status changes. Possible status: OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE or AVAILABLE.
}
public void onProviderEnabled(String provider) {
// called when the location provider is enabled by the user
}
public void onProviderDisabled(String provider) {
// called when the location provider is disabled by the user. If it is already disabled, it's called immediately after requestLocationUpdates
}
public void onLocationChanged(Location location) {
double latitute = location.getLatitude();
double longitude = location.getLongitude();
// do whatever you want with the coordinates
}
});
嗨亞歷山大感謝您的回覆,當我用,我得到了錯誤,如7月2日至一十四日:49:58.887: W/System.err(467):java.io.IOException:服務不可用 – 2012-02-14 02:22:38
您是否添加權限和access_fine_location權限? – 2012-02-15 18:37:55