-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't disconnect BLE devices when killing the app with background plugin on #261
Comments
After some testings, it appears that it is an issue caused by the Foregroundservice which doesn't close when I close the app. I tried to add the stopWithTask = "true" in the Android Manifest in the service field, but this doesn't force the service to stop when I swipe away the app! How can this happen? Do you have any suggestion about that, or things I must be aware of when trying to close a service together with the app? Any idea why it behaves like this? How can I force the service created by this plugin to stop? Can it be that the service is not "binded" to the app, and therefore it doesn't see the stopWithTask when I close the app? |
This is maybe related to issue #246 and #262 try to change. The problem is this plugin set the launchMode singleInstance to the cordova activity. You can try to use my fork meanwhile, where I have removed this launchMode
Note that the double quotes are important. |
@Albertazzi88 Thanks for your investigation. As I've only Samsung - did you manage to reproduce the issue with Samsung? I've hear about quite often that the service is still running however I am not able to reproduce that. Can you see in the logs that the service is still running or is the notification still present in the notification center? |
@katzer yes, I've noticed it also on a Samsung S3 Neo and S5 Neo, they both have this problem. The only way now is to make the app "crach" when I swipe it out using stopWithTask = "true" (don't know why it crashes anyway!), in this way everything is closed but an error message appear after the app is swiped out. |
I'm also seeing this in a similar fashion on a ZTE phone with Android 6.0: I'm writing an app that plays audio and should continue playing in the background. I enable background mode when the user starts playing audio and disable it when the audio stops playing. If I kill the app from within the task list while my audio plays (hence: while the background mode is enabled), its GUI completely disappears, nothing indicates that the app is still running, but its audio keeps playing. The only way I found to get it to stop is to restart the app and kill it again while background mode is disabled (it somehow seems to collect up the running player that went rogue...). |
I am facing exactly the same issue here. Oneplus 3T Android 7.1.1 Plugin version 0.7.2 I am connecting to a BLE device and when I swipe the app away, the connection is still on for some reason. Next time I start the app, I am not able to connect to the BLE device because it's in a 'stuck' state. As mentioned before, if I do not call .enable() then swiping away does terminate the BLE connection properly. A solution to this would be greatly appreciated. |
I should also note that DavidWiesner's pull request did not help. The problem persists. I even tried installing from his fork. There has to be a way to kill the service once the app is swiped away! Here are some logs from my device, AFTER I swiped the app away. It looks like it's still trying to run cordova stuff, even though the app has been closed:
|
When opening a deep link this plugin is loaded twice on the same process, so we cannot kill the app when destroying the first plugin. This line was first added by katzer#304 However the issue this was intended to solve was likely fixed by removing the launchMode singleInstance (already merged), as explained in here: katzer#261 (comment)
Hi all, since you are experts about BLE, ionic and Background, I have the following issue: don/cordova-plugin-ble-central#850 Any advise or pointer would be greatly appreciated, thanks a lot! |
I'm developing an app that interfaces with BLE devices.
Inside the app I can pair the devices and monitor their status.
If I close the app I want to disconnect the devices from the smartphone, and when I open it again, I want the app to reconnect automatically to known devices.
Everything works fine without using the background plugin, but I need to use it since the app needs to monitor the BLE devices even when it's in background.
The problem happens ONLY if I use the background plugin: if I open again the app, the known devices are not reconnected INSIDE the app, but it appears they are already/still connected to the smartphone from the previous time (even if not shown in the bluetooth devices in the phone settings).
It seems that the bluetooth connection to known devices isn't really being closed when I kill the app.
It appears like the device is still connected as therefore it doesn't show up when I scan in the app.
I can't reconnect until I close the app, switch off and then on again bluetooth, and reopen the app.
The steps are very simples:
Why this behaviour? Looks like something in the plugin prevents the bluetooth connection to be closed on app closing. I specify that:
Thanks
The text was updated successfully, but these errors were encountered: