Android - query if a sync account is checked for syncing -


how can query if sync account checked syncing or not?

the user doesn't control whether account selected syncing -- rather, (acount, contentauthority) pairs selected. example, gmail account can checked sync contacts, not calendar events.

here code check whether first entered "com.google-type" account syncs against google contacts. (note "com.google" type of account, not actual content of username. might have google apps account own domain name in there)

import android.provider.contactscontract;  accountmanager = accountmanager.get(this); account[] accounts = am.getaccountsbytype("com.google");         boolean syncenabled = contentresolver.getsyncautomatically(accounts[0], contactscontract.authority); 

this code fail if accounts[] size 0 (no accounts registered) , kind of meaningless in presence of multiple accounts. you'll need sort of reasonable selection account. there other ways hold of account well.

just becuase it's checked doesn't mean it's guaranteed sync. there additional conditions involved -- global sync setting (on/off), network availability, , whether , how periodic resync scheduled. contentresolver gateway queries well.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -