As proposed in this article Diamonds Are Forever. Services Are Not <https://www.androidguys.com/news/diamonds-are-forever-services-are-not/>: > If you are uncertain how to design an app to avoid the long-running service, post a clear description of the business scenario (not just low-level technical stuff) to the [android-developers] <https://groups.google.com/group/android-developers> group
I have one such scenario, that forces me looking for an implementation of a persistent service: 1. I need to write a custom email client, that will search for relevant mails. Search filters are very complex and constantly change. For that reason standard clients like gmail don't fit at all. 2. This will be used for a security system, therefore I need to check for new emails regularly at exact time. That's important, so I even don't care about battery drain. For that reason I cannot rely on solutions like WorkManager <https://developer.android.com/topic/libraries/architecture/workmanager>. It seems that service + AlarmManager will make the job, but... 3. If the service is restarted every time, it will loose its state, meaning the connection to the mailbox. Reconnecting and fetching mails takes a LOT of time, so it's very suboptimal. It seems that I have two desirable options: either serialize the state (which isn't possible, as the connection isn't serializable) or somehow make the service live forever. Is it feasible at all? Or maybe I missed something? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/a48fa41e-6cb5-4c43-88ce-fc2767fdf226n%40googlegroups.com.

