I have a SyncAdapter
that extends AbstractThreadedSyncAdapter
.
I execute a timer task in onPerformSync
met开发者_开发百科hod.
I want to check if the user turned off the Syncing so that I can stop the Timer Task.
I use ContentResolver.isSyncActive()
method to check this issue.
the problem is that it always returns false.
so how can I check if Sync is turned on/off ??
Thanks
You want to call ContentResolver.getMasterSyncAutomatically()
.
That will give you the global setting, whereas getSyncAutomatically
just checks whether an individual Account is enabled and isSyncActive
simply tells you whether a sync is happening at the moment.
The isSyncActive method just checks if a sync operation is currently running. You want getSyncAutomatically.
精彩评论