0
我用下面的方法來獲得當前的緯度&經度背後:如何獲得13號緯度的小數和經度
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
if (locationManager == null) {
Toast.makeText(LocationsListActivity.this,
"Location Manager Not Available", Toast.LENGTH_SHORT)
.show();
}
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location == null)
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
但問題的緯度和經度我只有小數點後面的8個數字(lat:52.51491445,lng:13.39044515) 我想要的是lat和lng我得到了13位小數點後的數字。
我該怎麼做? 謝謝
你確定lat只有8位小數嗎?或者它只是這個值的字符串表示... – Selvin 2012-04-20 12:36:05
它是,而不是一個字符串 – hectichavana 2012-04-20 12:36:33
http://en.wikipedia.org/wiki/Floating_point ...你看到的只是一個字符串...也許雙。 toString()使它看起來像只有8位小數 – Selvin 2012-04-20 12:38:02