我的问题是,我的服务已经实现了 LocationListener,似乎每 500 毫秒接收一次 GPS 更新。无论我在 requestLocationUpdates 函数中放入多少 minTime。
我的一段代码:
public class LocationService extends Service implements LocationListener {
LocationManager locMan;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
locMan = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locMan.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER;
locMan.requestLocationUpdates( LocationManager.GPS_PROVIDER, 60000, 1, this);
}
public void onLocationChanged(Location location) {
Log.d( "Loc", "Location has been changed" );
}
}
从我的主要活动中的一个按钮,我将调用 startService() ,之后它应该在后台运行,但它会提供持续更新。