简体   繁体   English

如何获取特定时间间隔的位置

[英]How to get Location for certain time interval

I'm doing my project in android..我在 android 做我的项目..

I want to get location for certain time interval (for fixed time) when button is clicked我想在单击按钮时获取特定时间间隔(固定时间)的位置

for ex: each 10 min for 4hrs I want to get current location address.例如:每 10 分钟,持续 4 小时,我想获取当前位置地址。

how to get this?如何得到这个? is there any timer control like visual basic?有没有类似visual basic的定时器控件? or any other method for doing it.或任何其他方法。 thax in advance提前致谢

you can use LocationListener which gets called when your location get changed and moreover you can provide time interval too您可以使用LocationListener ,当您的位置发生变化时它会被调用,而且您也可以提供时间间隔

public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener, Looper looper)

refer http://www.firstdroid.com/2010/04/29/android-development-using-gps-to-get-current-location-2/参考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);

// syntax: mlocManager.requestLocationUpdates(provider, minTime, minDistance, listener) //语法: mlocManager.requestLocationUpdates(provider, minTime, minDistance, listener)

you can set time and distance both in this method see ths syntax您可以在此方法中设置时间和距离,请参阅语法

you can see this link get current device location after specific interval there is a working example of how to get Location information at certain time period您可以看到此链接在特定时间间隔后获取当前设备位置有一个工作示例说明如何在特定时间段获取位置信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM