开发者

Synching accountmanager accounts

开发者 https://www.devze.com 2023-03-26 12:57 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消