我在做项目的Android ..如何获得位置进行一定的时间间隔
我想获得一定的时间间隔位置(固定时间)按钮被点击
为前时:每10分钟4小时我想获得当前位置地址。
如何得到它?有没有像Visual Basic一样的定时器控件?或任何其他方法来做到这一点。 thax提前
我在做项目的Android ..如何获得位置进行一定的时间间隔
我想获得一定的时间间隔位置(固定时间)按钮被点击
为前时:每10分钟4小时我想获得当前位置地址。
如何得到它?有没有像Visual Basic一样的定时器控件?或任何其他方法来做到这一点。 thax提前
您可以使用LocationListener
当你的位置得到改变其被调用,而且可以提供时间间隔过
public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener, Looper looper)
参考http://www.firstdroid.com/2010/04/29/android-development-using-gps-to-get-current-location-2/
LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener(context);
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 1,mlocL istener);
// 语法: mlocManager.requestLocationUpdates(provider,minTime,minDistance,listener)
您可以设置时间和距离都在这个方法中看到的部份语法
你可以看到这个链接get current device location after specific interval有一个如何在一定的时间段
获取位置信息的工作示例