blob: 4191ba5077927558d2dfce5f8ce232db42f170ea [file] [log] [blame]
Dirk Dougherty658d86e2010-02-08 10:22:43 -08001<p>This sample demonstrates how an application can communicate with a
2cloud-based service and synchronize its data with data stored locally in a
3content provider. The sample uses two related parts of the Android framework
4&mdash; the account manager and the synchronization manager (through a sync
5adapter).</p>
Megha Joshi00bf0f02009-11-18 14:54:03 -08006
Dirk Dougherty658d86e2010-02-08 10:22:43 -08007<p> The <a
8href="../../../reference/android/accounts/AccountManager.html">account
9manager</a> allows sharing of credentials across multiple applications and
10services. Users enter the credentials for each account only once &mdash;
11applications with the <code>USE_CREDENTIALS</code> permission can then query the
12account manager to obtain an auth token for the account. An authenticator (a
13pluggable component of account manager) requests credentials from the user,
14validates them with an authentication server running in the cloud, and then
15stores them to the account manager. This sample demonstrates how to write an
16authenticator for your service by extending the new <code><a
17href="../../../reference/android/accounts/AbstractAccountAuthenticator.html">
18AbstractAccountAuthenticator</a></code> abstract class. </p>
Megha Joshi00bf0f02009-11-18 14:54:03 -080019
Dirk Dougherty658d86e2010-02-08 10:22:43 -080020<p>The sync adapter (essential to the synchronization service) declares the
21account type and ContentProvider authority to the sync manager. This sample
22demosntrates how to write your own sync adapters by extending the <code><a
23href="../../../reference/android/content/AbstractThreadedSyncAdapter.html">
24AbstractThreadedSyncAdapter</a></code> abstract class and implementing the
25<code>onPerformSync()</code> method, which gets called whenever the sync manager
26issues a sync operation for that sync adapter. </p>
Megha Joshi00bf0f02009-11-18 14:54:03 -080027
Dirk Dougherty658d86e2010-02-08 10:22:43 -080028<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>
Megha Joshi00bf0f02009-11-18 14:54:03 -080030
Dirk Dougherty658d86e2010-02-08 10:22:43 -080031<p>When you install this sample application, a new syncable "SampleSyncAdapter"
32account will be added to your phone's account manager. You can go to "Settings |
33Accounts &amp; Sync" to view the account and change its sync settings. </p>
Megha Joshi00bf0f02009-11-18 14:54:03 -080034
35<img alt="Screenshot 1" src="../images/SampleSyncAdapter1.png" />
36<img alt="Screenshot 2" src="../images/SampleSyncAdapter2.png" />
Dirk Dougherty658d86e2010-02-08 10:22:43 -080037<img alt="Screenshot 3" src="../images/SampleSyncAdapter3.png" />