0

I am working on a GPS-enabled application and I need to record a point each N meters. However, I can't see how I can use onLocationChanged() method in the LocationListener or any other method/class. The onLocationChanged() method gives a point each second, and I need to store each N-meter point.

I believe that this has a simple solution, but since I am beginner in Android, cant find it.

Any help will be much appreciated.

4

3 回答 3

1

requestLocationUpdates有一个minDistance参数,如果我没记错的话,它就是你想要的。不过,我无法在真机上进行测试,所以我不知道它有多准确。

于 2010-11-29T04:51:52.370 回答
1

onLocationChanged中,将您获得的位置与您存储的最后一个位置进行比较。如果小于n米,丢弃它。如果没有,请存储它。冲洗。重复。

requestLocationUpdates编辑:等等,更容易 - 没有minDistance参数?见这里:http: //developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates

于 2010-11-29T04:51:59.767 回答
0

它运行良好 myManager = ((LocationManager) ApplicationController.getAppContext().getSystemService( Context.LOCATION_SERVICE )); myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1 * 1000, 0.00001f, this);

mintime =1000ms 它总是在调用....

于 2010-12-09T10:08:11.723 回答