Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 离子背景地理定位停止工作_Ionic Framework_Ionic4_Tracking_Android Gps - Fatal编程技术网

Ionic framework 离子背景地理定位停止工作

Ionic framework 离子背景地理定位停止工作,ionic-framework,ionic4,tracking,android-gps,Ionic Framework,Ionic4,Tracking,Android Gps,使用这段代码,我可以获得gps数据和检索地址,所有这些都可以在后台正常工作,几分钟后,大约20分钟后,应用程序semms停止执行我想执行的操作。 我试过电池特许权和其他可能的事情,我试过背景服务。 但在隆格时间之后,似乎并没有什么东西可以在后台获得位置。 任何建议 this.backgroundGeolocation.configure(config).then(() => { console.log('backgroundGeolocation configconfigconfigc

使用这段代码,我可以获得gps数据和检索地址,所有这些都可以在后台正常工作,几分钟后,大约20分钟后,应用程序semms停止执行我想执行的操作。 我试过电池特许权和其他可能的事情,我试过背景服务。 但在隆格时间之后,似乎并没有什么东西可以在后台获得位置。 任何建议

this.backgroundGeolocation.configure(config).then(() => {


console.log('backgroundGeolocation configconfigconfigconfigconfigconfig');

this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {

    console.log(location);  
    this.ngZone.run(() => {


        this.geolocationService.nativeGeocoder.reverseGeocode(location.latitude, 
        location.longitude).then((result: NativeGeocoderResult[]) =>{

      console.log("JSON.stringify(result[0]",JSON.stringify(result[0]));
            this.comunenoreplace = result[0]['locality'];
            this.comune = result[0]['locality'].replace(/[^A-Z0-9]+/ig, "-");
            this.provincia = result[0]['subAdministrativeArea'].replace(new RegExp('Città Metropolitana di|Provincia di', 'g'), '');
            this.globalLatitude = location.latitude;
            this.globalLongitude = location.longitude;


          }).catch((error: any) => console.log("reverseGeocode", error));


    });
    // IMPORTANT:  You must execute the finish method here to inform the native plugin that you're finished,
    // and the background-task may be completed.  You must do this regardless if your operations are successful or not.
    // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
   // this.backgroundGeolocation.finish;
  });
});
你可以使用

它只是修改应用程序的睡眠模式,使其在后台工作(而不会终止进程)

如果进程被终止,则应用程序可能会停止发送数据

然后是“cordova.plugins.backgroundMode.excludeFromTaskList()”;使其从任务列表中消失(Android 5.0+)

希望这有帮助:)