I am trying to create a background periodic task with WorkManager but my task is getting killed when we swipe the app away from the app manager.
Firstly, I thought that it was a problem of my phone (Samsung with Android 10) but I tried with an emulator (Pixel 2 Android 10) and the same problem is occuring.
I followed instructions to debug WorkManager and I compared my app with an open-source app that work exactly the way I want (K9-Mail), here what I found :
When the app is running :
JOB #u0a137/0: 9699ebf fr.alexis.myapp/androidx.work.impl.background.systemjob.SystemJobService
u0a137 tag=*job*/fr.alexis.myapp/androidx.work.impl.background.systemjob.SystemJobService
Source: uid=u0a137 user=0 pkg=fr.alexis.myapp
JobInfo:
Service: fr.alexis.myapp/androidx.work.impl.background.systemjob.SystemJobService
Requires: charging=false batteryNotLow=false deviceIdle=false
Extras: mParcelledData.dataSize=180
Network type: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10137] ]
Minimum latency: +15m0s0ms
Backoff: policy=1 initial=+15m0s0ms
Has early constraint
Required constraints: STORAGE_NOT_LOW TIMING_DELAY CONNECTIVITY [0x90000008]
Satisfied constraints: STORAGE_NOT_LOW CONNECTIVITY DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED WITHIN_QUOTA [0x13400008]
Unsatisfied constraints: TIMING_DELAY [0x80000000]
Uid: active
Tracking: CONNECTIVITY STORAGE TIME QUOTA
Implicit constraints:
readyNotDozing: true
readyNotRestrictedInBg: true
Network: 101
Standby bucket: ACTIVE
Enqueue time: -48s964ms
Run time: earliest=+14m11s36ms, latest=none, original latest=none
Last run heartbeat: 0
Ready: false (job=false user=true !pending=true !active=true !backingup=true comp=true)
Compared to the open-source app that is working :
JOB #u0a138/1: 6a789c1 com.fsck.k9/androidx.work.impl.background.systemjob.SystemJobService
u0a138 tag=*job*/com.fsck.k9/androidx.work.impl.background.systemjob.SystemJobService
Source: uid=u0a138 user=0 pkg=com.fsck.k9
JobInfo:
Service: com.fsck.k9/androidx.work.impl.background.systemjob.SystemJobService
Requires: charging=false batteryNotLow=false deviceIdle=false
Extras: mParcelledData.dataSize=180
Network type: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10138] ]
Minimum latency: +14m59s992ms
Backoff: policy=1 initial=+5m0s0ms
Has early constraint
Required constraints: STORAGE_NOT_LOW TIMING_DELAY CONNECTIVITY [0x90000008]
Satisfied constraints: STORAGE_NOT_LOW CONNECTIVITY DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED WITHIN_QUOTA [0x13400008]
Unsatisfied constraints: TIMING_DELAY [0x80000000]
Tracking: CONNECTIVITY STORAGE TIME QUOTA
Implicit constraints:
readyNotDozing: true
readyNotRestrictedInBg: true
Network: 101
Standby bucket: ACTIVE
Enqueue time: -1m5s968ms
Run time: earliest=+13m54s24ms, latest=none, original latest=none
Last run heartbeat: 0
Ready: false (job=false user=true !pending=true !active=true !backingup=true comp=true)
When I kill the two apps, my app is just removed of the list of running jobs compared to the other that is still in the list ..
UPDATE: After more tests, I have found that all working applications on my devices are referenced on Play Store, is it a known issue or a wrong lead ?
User contributions licensed under CC BY-SA 3.0