Android Cordova长期运行定位服务

Android Cordova长期运行定位服务,android,cordova,cordova-plugins,long-running-processes,Android,Cordova,Cordova Plugins,Long Running Processes,我对应用程序何时进入后台以及应用程序进入后台的含义感到困惑 我正在尝试一个长时间运行的服务来检测位置的变化 Plugin.xml: <service android:name="MyLocationService.java" /> MyPlugin.java public class MyPlugin extends CordovaPlugin { public static CallbackContext callbackContext; public boo

我对应用程序何时进入后台以及应用程序进入后台的含义感到困惑

我正在尝试一个长时间运行的服务来检测位置的变化

Plugin.xml:

<service android:name="MyLocationService.java" />
MyPlugin.java

public class MyPlugin extends CordovaPlugin {

    public static CallbackContext callbackContext;

    public boolean execute(String action, JSONArray data, CallbackContext callbackContext) {
        Activity activity = this.cordova.getActivity();
        Intent myIntent = new Intent(activity, MyLocationService);
        MyPlugin.callbackContext = callbackContext;
        activity.startService(myIntent);
    }
}
我的问题是:

onLocationChanged何时停止接收更新? 我知道当我调用locationManager.removeUpdates时,它将停止接收更新,但我想知道还有什么其他条件会导致它停止接收更新…可能是当应用程序进入后台时? 什么时候我将无法通过Cordova调用javascript回调? 有没有更好的方法让长期运行的服务在必要时唤醒应用程序?
public class MyPlugin extends CordovaPlugin {

    public static CallbackContext callbackContext;

    public boolean execute(String action, JSONArray data, CallbackContext callbackContext) {
        Activity activity = this.cordova.getActivity();
        Intent myIntent = new Intent(activity, MyLocationService);
        MyPlugin.callbackContext = callbackContext;
        activity.startService(myIntent);
    }
}