How can I create a low power background task or service in Android, that is not visible in the notifications bar and checks about every second for new values added to the database. I don't want to use a foreground service. I tried with a Worker, but it won't start every second.
Asked
Active
Viewed 35 times
0
-
Trying to keep your own connection alive in a background process is an anti-pattern, as it drains the user's battery. Instead, consider implement a listener in a server-side process somewhere, and then send a data message to the device using Firebase Cloud Messaging, where your service will then be awoken to handle that message. See https://stackoverflow.com/q/56691306 – Frank van Puffelen Oct 01 '21 at 14:25