I am trying to create SyncAdapter running background operation (without foreground notification).
It is working, except the case when activity (task) which triggered ContentResolver.requestSync(...)
is swiped away from recent applications. In that case process is killed and onPerformSync(...)
is not finished.
I know, this is expected Android behavior, but in regular Service
I would set
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
return START_REDELIVER_INTENT;
}
or maybe use
@Override
public void onTaskRemoved(Intent rootIntent) {
super.onTaskRemoved(rootIntent);
restartSynchronization();
}
to retry synchronization, but this is not working in the SyncAdapterService.
How can I ensure synchronization continues/retry after activity is swiped away from recent applications?
Thank you in advance.