I'm just writing to try to understand when a service running in the foreground is disabled by the Android system. I developed an alarm app and after choosing the text and time data for the alarms, I close the app and only its service is running in the foreground, sometimes it works for a day, sometimes two, but suddenly, just like that, it is stopped by Android with no apparent error. After a while it works again, but then it gives an error because the alarm data disappears with the service, as I store it in a list. I even used a code so that the app doesn't optimize the battery.
I saw a discussion more or less on the topic in 2019, but as it was very old I decided to post another one.
I have two questions:
1 - This is normal, as I have an alarm app that always works, even with the battery optimizer being marked.
2 - Will I have to use a database to store the alarm data and when Android turns it on again I load it from it?