I am using sync adapter on my app to perform periodic sync . But the problem is when a sync is running , and I close the app at that time , sync stopped . As far as I know sync adapter always run on background , closing the app won't affect sync process . But why is this happening ? How can I overcome this problem ?
Asked
Active
Viewed 893 times
1 Answers
0
As far as having it run continuously goes, keep in mind that by design, the Android system may terminate your service process at any time. You can influence this a bit, but you cannot prevent the system from killing your service.
So for your periodical actions, it would be best to use AlarmManager with a recurring alarm. Your service would then basically be one-shot, i.e. perform the action once and then exit.
For some code, look here for example: