I'm a newb with the syncAdapter . i've watched the google IO video (lecture presentation here) , and i've read 2 tutorials (here and here) about it .
i've also tried out the code of the tutorials and it's frustrating that i can't figure out how to implement the syncAdapter correctly .
what i believe is that some of the preferences (either in the manifest or on the xml files) are just wrong , but i can't find out why .
i've succeeded to allow adding the syncing account and also show it with its icon .
however , i'm facing some weird problems that i can't figure out why they occur:
allow the account to synchronize . the end user cannot press on the syncing button . it also doesn't seem to auto-sync even though i've tried to add such a thing upon adding the account .
after adding the account , the end user can see a weird description of the account : "res/xml/authenticator.xml" . not sure where its being set.
when clicking the account (after it was added) , i see an empty list (which is proba. how do i add more items there ? in the future , i need to also sync with facebook and gmail , but i can't event succeed with adding my own contentProvider to this list.
i don't need to do real authorization so i just use the next code instead inside the activity that extends from AccountAuthenticatorActivity :
accountManager.addAccountExplicitly(account, PASSWORD, null);
final Intent intent = new Intent();
intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, USERNAME);
intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
setAccountAuthenticatorResult(intent.getExtras());
setResult(RESULT_OK, intent);
finish();
i've also tried to set auto-syncing and enable syncing by using what's described here.
About 1) yes you can't sync if there isn.'t an internet connection. The reason is that (although there isn't a proper definition of a sync adapter) a sync adapter is a component that is supposed to be used to sync a backbone with your local data. If there is no connection it does not make sense to start the sync. Actually this is true only in theory becausr I had to develope a sybc adapter even if there was no backbone database.
What I did was to write a component that is called by the sync adapter when it is triggered and by my own application when the sync is necessary even if there is no connection