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