Closed bokolob closed 1 year ago
When you say "close my application" do you mean kill the application, or just send it to the background? What if you go to Settings and press "Force stop"?
I meant closing :) I swiped it out from apps list :) Sorry, I’m using android just for test my application for the first time.
And I checked with debugger - Service.selfStop was actually called. Maybe watchers should be removed before exit.
So you killed the app via the "task manager"?
No, not killed, I tried to explain in my previous comment
I didn’t use any special software like task managers
I meant closing :) I swiped it out from apps list
Sorry I missed that bit (that is indeed what I meant by "task manager"). If you remove the watchers before closing the app does it help?
I haven’t tried yet. I’ve got this idea just now :) And by the way - if I build plugin by myself, how do I add to capacitor project? Should I somehow change gradle configuration?
For experimenting, just modify BackgroundGeolocation.java and BackgroundGeolocationService.java from your editor. These changes will be wiped by reinstalling the background-geolocation NPM package.
Is there any app close event in Ionic? Is there any way to removeWatcher
?
Same issue here killing the app swiping it up from the recent apps.
I didn't find a way to call removeWatcher
if the app is being killed by the user.
Did anyone find a solution?
What device and Android version are you using?
@diachedelic Pixel 5 with API 33 (Android 13)
I am not able to reproduce this bug. If you can reliably reproduce this, please add the following to BackgroundGeolocationService.java and see if onUnbind gets called when the application is killed. If it does, we can make the service self-destruct.
@Override
public boolean onUnbind(Intent intent) {
Logger.error("onUnbind called");
return true;
}
@diachedelic it is called! With this code the error is fixed:
@Override
public boolean onUnbind(Intent intent) {
Logger.error("onUnbind called!!!!!!!!");
for (Watcher watcher : watchers) {
watcher.client.removeLocationUpdates(watcher.locationCallback);
watchers.remove(watcher);
if (getNotification() == null) {
stopForeground(true);
}
}
return true;
}
Will you update the main repo with this fix?
Can you test this code please?
@Override
public boolean onUnbind(Intent intent) {
for (Watcher watcher : watchers) {
watcher.client.removeLocationUpdates(watcher.locationCallback);
watchers.remove(watcher);
}
stopSelf();
return false;
}
@diachedelic It works!
This has been published in v1.2.6.
Describe the bug Hello. When I close my application the background service keeps running. But it seems that it doesn't do anything. After that, when I starts application again It couldn't handle GPS events and produces the next stacktrace.
Moreover, application becomes unusable until device reboot.
Smartphone (please complete the following information):