How do I stop the Android App properly?

Hi,

when I am once connected to a Meshtastic device via Bluetooth, a notification appears in the phone, that I am connected and it shows how many devices are online. When I disconnect on the right most tab page (“None (disable)”) then the notification still appears as “disconnected”.

When I close the app via recent apps, this notification still shows up. Same thing with exiting via back button. How do I quit the app properly without force closing from the Android settings?

Thanks,
Drew

1 Like

If you switch to none, the service disconnects (but uses essentially no memory or CPU). So I wasn’t super in a hurry to kill it. The next time you reboot the phone it won’t even restart the service.

Would you mind putting a bug in for the Android project on GitHub and we will fix this eventually?

Alright, thanks for the fast answer, glad to know that no memory and CPU is used after switching to none.

In your opinion, is it save to force close the app in the “none” state?

I will open a issue in GitHub, sure.

Thanks for the nice project, Sir :wink:

re: is it safe to force quit
yep. Though unnecessary, because our service uses essentially no ram and only a very tiny amount of CPU (if connected to a device, or zero CPU if not)

Ok.

It is just about getting the notification away, without disabling it via Android. I like clear Notification bars :wink:

Turn off the bluetooth before closing the application, close it. press again in the notification that remains open, close it again even in the background.
This will close it completely.
the conflict is due to very excessive bluetooth permission.
I hope I was helpful :smile:

It works kind of.

switching to none and following your steps does not work. (I get a prompt to enable Bluetooth, but it does not matter if I allow or deny) bevor closing.

Keeping the device connected and disabling Bluetooth and following your steps is working, but the notification reappears after enabling Bluetooth again… (Just realized this is only on my Pixel2, on my Xperia XZ2 Compact, the steps are working, both Android 10)

By the way, giving Location permission only “during using the app”, the app complaints about missing permissions. Giving full permissions keeps the location indicator in the notification bar active, even after a force close. A reboot resolved the issue.

Edit: Issue opened

1 Like

You did well to open the issue in GitHub, let’s see if they can solve it. I think it will take some time, they have to rewrite the application’s authorization rules and its Android service behaviors

This change (when we eventually do it), will be fairly easy. We just need to stop the service if the user chooses none. It has been a low priority, because (really really) there is no need for this. When not connected to the radio the app uses virtually no RAM or CPU (or more accurately the OS can take all the apps RAM back if it needs it).

By the way, giving Location permission only “during using the app”, the app complaints about missing permissions. Giving full permissions keeps the location indicator in the notification bar active, even after a force close. A reboot resolved the issue.

giving “only while using the app” location permissions can’t allow the app to function properly for two reasons:

  • The OS will not allow access to bluetooth devices when we don’t have location permissions (even if we don’t want to use the GPS, the presence of bluetooth devices can provide approximate location info so Android restricts it). If our app happens to not be currently visible to the user, android considers it to be “not during use of the app” (even if we have a background service running)

  • To connect to the bluetooth device when it wakes/comes in range - we need to have a service running so the bluetooth connect event happens.

btw: I also like clear notification bars, and we could achieve that by using a new bluetooth API android now provides, but that would only work on very new Android releases. So we don’t yet support this API. More info here:

3 Likes

Nice piece of information with the Android location restrictions. And always thanks for your time @geeksville.

For stopping the service I would suggest to add a “x” or close button to the notification, which switches to “none” and stops the service. (Similar to the “x” in the youtube background play notification.)

1 Like