//Show the current coordinates (Convert to String and round off - 6 decimal places)
String printLat = new DecimalFormat("0.######").format((double)currentLat);
String printLon = new DecimalFormat("0.######").format((double)currentLon);
AlertDialog alert = new AlertDialog.Builder(Main.this).create();
alert.setTitle("Current Location:");
alert.setMessage("Latitude: " + printLat+ "\n" + "Longitude: " + printLon);
alert.setButton("Close", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1)
{
// TODO Auto-generated method stub
//Alert Dialog won't work without a listener
//Do nothing (This will simply close your alert dialog)
}
});
alert.show();
这是我的主要类(class)的一部分。
我应该获取从模拟器发送的内容。但我得到的不是精确值,而是:
纬度 - 14.069315 经度 - 121.323738
但是我发送了这个(从我的模拟器控件) 纬度 - 14.069316 经度 - 121.323739
这只是一个十进制数和一个小值的问题,但我担心这是否会对我的应用程序上显示的内容产生很大影响,因为我将使用这些值在我的 Google map 上添加标记.
有什么建议吗?
最佳答案
这对我来说听起来像是舍入误差。
我不会担心这么多的错误,因为 number at the sixth decimal place equates to less than 1 meter on the ground (depending what latitude the location is at) .
关于java - 从 Eclipse 的模拟器控制返回不准确的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11404358/