Eventually terminates, even though "Power optimization" is disabled and the app is "pinned"

I have K-9 running with a single IMAP account, and I need IDLE notifications to arrive as soon as possible.

This more or less works, except sometimes K-9 just stops running. How do I debug this?

The phone is OnePlus 5t, and I have both “power optimization” turned off for K-9, and have K-9 “pinned” by tapping on three dots in the “program manager” and tapping “lock”.

This works well for, say, “Syncthing”, which does not get killed by the power manager, also works for “Linphone”, which can also run for weeks without interruptions.

However, K-9 eventually terminates for an unknown reason. Either there is something that makes the app exit, or it does something that even a appeased power manager considers unworthy.

Any suggestions?

Welcome @abjectTeal5 :wave:

When using Push (IMAP IDLE) K-9 Mail is running a foreground service. That is a signal to both the system and the user that the app is doing work in the background. It should prevent the system from killing the app’s process, unless a foreground app needs additional memory. But even then the system should kill all other apps first before it gets to the ones running foreground services.
K-9 Mail’s foreground service is also configured to tell the system it wants to be restarted when it had to be killed by the system.

It seems like OnePlus is especially bad at being a proper Android system when it comes to background apps. See https://dontkillmyapp.com/. I don’t think there’s anything K-9 Mail can do about that.

My advice would be to consult this site before getting a new device.

The app called “@Voice” TTS has implemented a feature that , when an app is started, warns the user if it has been killed by the power manager. (And suggests looking at this page: @Voice stopped by system to )

Could a similar feature be added to K-9?

At least I would be sure it hasn’t crashed.

I don’t know how an app could distinguish between the different cases why it hasn’t been running. The app might have been updated, the device might have been rebooted, the user might have manually killed the app, etc.

Anyway, it feels like the wrong approach to have all apps implement a “feature” like this. Vendors need to fix their Android flavors to at least ask users before killing background apps in the name of power optimization.

I might be way off on this suggestion, but what about adding the K9 widget to your home screen? I use the 1x1 and selected an account. Works perfectly to show number of new messages. My logic here is the widget refreshes and should keep K9 working in the background.

Do you use any apps that claim to clean the device and free up memory/ram etc?