I am writing an android application that will start sync for all accounts added under "Account & sync" settings.I am fetching all the added accounts using the following code
AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE);
Account[]acs = am.getAccounts();
After fetching the account I want to start sync f开发者_开发知识库or each account
for(Account ac:acs){
ContentResolver.requestSync(ac,authority,extras);
}
My question is how do i fetch the authority for the retrieved account ?
A far simpler answer is simply to turn off the global sync enabled flag and then turn it back on. Android starts a full sync by defualt in this case.
See ContentResolver.setMasterSyncAutomatically()
.
Your app will need appropriate permissions in the manifest to be allowed to change that flag.
精彩评论