我正在尝试获取从用户设置的预定位置到用户当前位置的距离。问题是它返回的距离到处都是,而且非常不准确。另外,SkettiList.get(i).Lat
和 SkettiList.get(i).Lon
是用户设置的位置的常量经度和纬度,而 Lat
和 Lon
是用户当前的纬度和经度位置。这是我的
代码:
float[] results=new float[1];
Location.distanceBetween(SkettiList.get(i).Lat, SkettiList.get(i).Lon,Lat,Lon, results);
Log.i("SKT: ",results[0]+"");
最佳答案
GPS 只会在短距离内发挥作用,如果您处于静止状态,则会出现这种情况 稍微弹跳一下。
也就是说你应该确保你使用的是 FINE
<manifest ... >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
...
</manifest>
http://developer.android.com/guide/topics/location/strategies.html
在我的申请中,我会扔掉与上次相差不至少 10 米的任何东西 收到位置信息。
关于java - 测量短距离 Android GPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27747753/