Dirk Dougherty | 658d86e | 2010-02-08 10:22:43 -0800 | [diff] [blame] | 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 |
John Evans | 15ef1a8 | 2011-04-04 13:38:01 -0700 | [diff] [blame] | 5 | adapter). It also demonstrates how to provide users the ability to create |
| 6 | and edit synchronized contacts using a custom editor.</p> |
Megha Joshi | 00bf0f0 | 2009-11-18 14:54:03 -0800 | [diff] [blame] | 7 | |
Dirk Dougherty | 658d86e | 2010-02-08 10:22:43 -0800 | [diff] [blame] | 8 | <p> The <a |
| 9 | href="../../../reference/android/accounts/AccountManager.html">account |
| 10 | manager</a> allows sharing of credentials across multiple applications and |
| 11 | services. Users enter the credentials for each account only once — |
| 12 | applications with the <code>USE_CREDENTIALS</code> permission can then query the |
| 13 | account manager to obtain an auth token for the account. An authenticator (a |
| 14 | pluggable component of account manager) requests credentials from the user, |
| 15 | validates them with an authentication server running in the cloud, and then |
| 16 | stores them to the account manager. This sample demonstrates how to write an |
| 17 | authenticator for your service by extending the new <code><a |
| 18 | href="../../../reference/android/accounts/AbstractAccountAuthenticator.html"> |
| 19 | AbstractAccountAuthenticator</a></code> abstract class. </p> |
Megha Joshi | 00bf0f0 | 2009-11-18 14:54:03 -0800 | [diff] [blame] | 20 | |
Dirk Dougherty | 658d86e | 2010-02-08 10:22:43 -0800 | [diff] [blame] | 21 | <p>The sync adapter (essential to the synchronization service) declares the |
| 22 | account type and ContentProvider authority to the sync manager. This sample |
| 23 | demosntrates how to write your own sync adapters by extending the <code><a |
| 24 | href="../../../reference/android/content/AbstractThreadedSyncAdapter.html"> |
| 25 | AbstractThreadedSyncAdapter</a></code> abstract class and implementing the |
| 26 | <code>onPerformSync()</code> method, which gets called whenever the sync manager |
| 27 | issues a sync operation for that sync adapter. </p> |
Megha Joshi | 00bf0f0 | 2009-11-18 14:54:03 -0800 | [diff] [blame] | 28 | |
Scott Main | 8e56770 | 2011-10-14 11:05:08 -0700 | [diff] [blame] | 29 | <p class="note"><strong>Update:</strong> This sample has been updated for Android 4.0 to |
| 30 | demonstrate new features, including: syncing and viewing contact groups, handling the "invite" |
| 31 | intent, and a few other improvements.</p> |
| 32 | |
Dirk Dougherty | 658d86e | 2010-02-08 10:22:43 -0800 | [diff] [blame] | 33 | <p> The cloud-based service for this sample application is running at: </p> |
John Evans | 15ef1a8 | 2011-04-04 13:38:01 -0700 | [diff] [blame] | 34 | <p style="margin-left:2em;">http://samplesyncadapter2.appspot.com/</p> |
Megha Joshi | 00bf0f0 | 2009-11-18 14:54:03 -0800 | [diff] [blame] | 35 | |
Dirk Dougherty | 658d86e | 2010-02-08 10:22:43 -0800 | [diff] [blame] | 36 | <p>When you install this sample application, a new syncable "SampleSyncAdapter" |
| 37 | account will be added to your phone's account manager. You can go to "Settings | |
| 38 | Accounts & Sync" to view the account and change its sync settings. </p> |
Megha Joshi | 00bf0f0 | 2009-11-18 14:54:03 -0800 | [diff] [blame] | 39 | |
| 40 | <img alt="Screenshot 1" src="../images/SampleSyncAdapter1.png" /> |
| 41 | <img alt="Screenshot 2" src="../images/SampleSyncAdapter2.png" /> |
Dirk Dougherty | 658d86e | 2010-02-08 10:22:43 -0800 | [diff] [blame] | 42 | <img alt="Screenshot 3" src="../images/SampleSyncAdapter3.png" /> |