I am building an android app for which I need to check the sync setting of each individual account registered in the device. I know that I can do it through ContentResolver class but I am having some problem with it. I’ve managed to get the list of all accounts on the device but I don’t know where to get the relevant authority of a specific account at run time. Below is the code:
AccountManager acm = AccountManager.get(getApplicationContext());
Account[] acct = acm.getAccounts();
for(int i=0;i<acct.length;i++){
int p = ContentResolver.getIsSyncable(acct[i], null);
Log.i(TAG,"account name is"+acct[i].name);
Log.i(TAG,"answer to syncable is: "+String.valueOf(p));
The getIsSyncable(Account am,String authority) asks for an account and an authority. As you can see I am passing in NULL instead of the actual authority. Does anyone know of a way I can find the authority to the relevant account?
You can retrieve the known SyncAdapters and then query the
ContentResolverOutput:
11-15 17:12:51.899: DEBUG/syncsample(4572):
com.google.android.music.MusicContent–com.google 11-15 17:12:51.899:
INFO/syncsample(4572): account name: xxxxxxxxx@gmail.com 11-15
17:12:51.899: INFO/syncsample(4572): syncable: 1 11-15 17:12:51.899:
INFO/syncsample(4572): account name: xxxxxx@google.com 11-15
17:12:51.899: INFO/syncsample(4572): syncable: 0