How to encode the sync now operation on Android?

I have a synchronization adapter for my database and at certain points in the use of the application, now it needs to synchronize the database. I would like to activate the synchronization adapter as if its synchronization time had surfaced, and then set the synchronization time again (ie 4 hours from this “synchronize now” event).

+5
android android-syncadapter
Dec 16 '10 at 21:57
source share
1 answer

I think (not tested) the best solution is already defined in ContentResolver.

ContentResolver.requestSync(account, authority, extras); 

so that you can do the following:

 AccountManager am = AccountManager.get(context); Account account = null; am.getAccountsByType(mytype); for(Account a : accounts) { if (am.getUserData(account, key)) { account = a; break; } } Bundle extras = new Bundle(); extras.putString(EXTRA_mystuff, myvalue); ContentResolver.requestSync(account, authority, extras) 
+4
Mar 20 2018-11-11T00:
source share



All Articles