我正在尝试创建一个持续的GPS监听器,每x分钟将其位置(经度和纬度坐标)发送到Web服务器。在点击按钮时,它还将其位置发送到Web服务器。我意识到要获取GPS信号,您需要键入多久才能找到一个位置,但是如何编写程序以获取GPS位置并在x分钟内发送其坐标(即使在后台运行时也是如此,而不是通过按钮按下)?
并且。
//在单击中
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, whatshouldIputhere?, 0, this);
并且。
public void onLocationChanged(Location location) {
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
}
}