How to configure syncAdapter?

I am new to syncAdapter. I watched a video on google IO (lecture presentation here ) and I read 2 tutorials ( here and here ).

I also tried the tutorial code, and it disappoints me that I cannot figure out how to correctly implement syncAdapter.

I believe that some of the preferences (either in the manifest or in the xml files) are simply wrong, but I cannot understand why.

I managed to add a synchronization account and also show it with its icon.

however, I encounter some strange problems that I cannot understand why they occur:

  • allow you to synchronize your account. The end user cannot click the sync button. it also doesn't seem to auto-sync, although I tried to add such a thing when adding an account.

  • after adding the account, the end user may see a strange account description: "res / xml / authenticator.xml". not sure where to install it.

  • when you click on the account (after adding it), I see an empty list (which, it seems to me, will add more elements in the future, I also need to synchronize with facebook and gmail, but I can not succeed with adding my own ContentProvider to this list.

I don't have to do real authorization, so I just use the following code instead in activities that extend 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 also tried to set up automatic synchronization and enable synchronization using the one described here .

+8
android synchronization android-contentprovider android-syncadapter
source share
1 answer

Approximately 1) yes, you cannot sync if there is no internet connection. The reason is that (although there is no proper definition of the synchronization adapter), the synchronization adapter is the component that you intend to use to synchronize the core network with your local data. If there is no connection, it makes no sense to start synchronization. In fact, this is true only in theory, because I had to develop a sybc adapter, even if there was no base database.

I did to write a component that is called by the synchronization adapter when it starts, and by my own application when synchronization is required, even if there is no connection

0
source share

All Articles