My Sync Adapter works correctly Periodic Synchronization with Android Marshmallow, but it does not work with KitKat and Lollipop. In these two versions, periodic synchronization does not work, if it works manually. I have searched for solutions and I have not found anything on the web. The code, which I think is the problem is this:
if (newAccount != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
SyncRequest request = new SyncRequest.Builder()
.syncPeriodic(SYNC_INTERVAL, SYNC_FLEXTIME)
.setSyncAdapter(newAccount, authority)
.setExtras(new Bundle())
.build();
ContentResolver.requestSync(request);
} else {
ContentResolver.addPeriodicSync(newAccount, authority, new Bundle(), SYNC_INTERVAL);
}
}
Greetings and thanks for the attention.