0

I would like to start my foreground service every 30 minutes to synchornize data with server.

What I have in mind
Setup a periodic task that just starts my foreground synchronization service.

What I have tried so far

  1. Broadcast Receiver with android.net.conn.CONNECTIVITY_CHANGE. This was my first approach. Try to synchronize data only if device lost connection sometime and recovered it later on. This doesn't work anymore for newer android versions. When app is killed, this broadcast receiver stop working.

  2. AlarmManager

  3. AndroidX.Work.Worker

  4. JobService

All what I tried stop working after app killed. So my question is the following. Is there a way of achieving what I'm aming for in android 10 or above?

dembo
  • 75
  • 5
  • Define "app killed" – Some random IT boy Feb 20 '23 at 09:07
  • Forced stop. Removed from task manager. – dembo Feb 20 '23 at 09:14
  • If a user force-stops your app, any pending work is removed from the processing queue. [Here are some furhter details](https://stackoverflow.com/a/52605503/9248718) – Some random IT boy Feb 20 '23 at 09:17
  • But it must be a way of achieving it. Whatsapp does it. Turn off network connection. Send a message. Kill app. Turn on network connection some minutes later and the unsent message is automatically sent without entering in application again. (This is what I tried to achieve with my first try). – dembo Feb 20 '23 at 09:44
  • It's dependent on the OEM as it's mentioned on the link I attached. I cannot reproduce what you mentioned with my Pixel 3XL – Some random IT boy Feb 20 '23 at 10:08

0 Answers0