I want to enable auto sync in account settings in my app programmatically. I've set up the SyncAdapter, declared it in manifest, I added account and after this action I tried:
ContentResolver.setSyncAutomatically(account, authority, true);
ContentResolver.setMasterSyncAutomatically(true);
but it's not working. There is the same questions on SE:
- Android how to enable/disable auto sync programmatically
- general sync settings "auto-sync" checkbox programmatically
- Toggle on auto-sync progarammatically in Android
- general sync settings "auto-sync" checkbox programmatically
but they are too old, and in them I found, that I need to use ContentResolver.setMasterSyncAutomatically(true)
, but it's not working on my Android 7, Android 9.