1 <p>This sample demonstrates how an application can communicate with a 2 cloud-based service and synchronize its data with data stored locally in a 3 content provider. The sample uses two related parts of the Android framework 4 — the account manager and the synchronization manager (through a sync 5 adapter).</p> 6 7 <p> The <a 8 href="../../../reference/android/accounts/AccountManager.html">account 9 manager</a> allows sharing of credentials across multiple applications and 10 services. Users enter the credentials for each account only once — 11 applications with the <code>USE_CREDENTIALS</code> permission can then query the 12 account manager to obtain an auth token for the account. An authenticator (a 13 pluggable component of account manager) requests credentials from the user, 14 validates them with an authentication server running in the cloud, and then 15 stores them to the account manager. This sample demonstrates how to write an 16 authenticator for your service by extending the new <code><a 17 href="../../../reference/android/accounts/AbstractAccountAuthenticator.html"> 18 AbstractAccountAuthenticator</a></code> abstract class. </p> 19 20 <p>The sync adapter (essential to the synchronization service) declares the 21 account type and ContentProvider authority to the sync manager. This sample 22 demosntrates how to write your own sync adapters by extending the <code><a 23 href="../../../reference/android/content/AbstractThreadedSyncAdapter.html"> 24 AbstractThreadedSyncAdapter</a></code> abstract class and implementing the 25 <code>onPerformSync()</code> method, which gets called whenever the sync manager 26 issues a sync operation for that sync adapter. </p> 27 28 <p> The cloud-based service for this sample application is running at: </p> 29 <p style="margin-left:2em;">http://samplesyncadapter.appspot.com/users</p> 30 31 <p>When you install this sample application, a new syncable "SampleSyncAdapter" 32 account will be added to your phone's account manager. You can go to "Settings | 33 Accounts & Sync" to view the account and change its sync settings. </p> 34 35 <img alt="Screenshot 1" src="../images/SampleSyncAdapter1.png" /> 36 <img alt="Screenshot 2" src="../images/SampleSyncAdapter2.png" /> 37 <img alt="Screenshot 3" src="../images/SampleSyncAdapter3.png" /> 38