1*90c8c64dSAndroid Build Coastguard Worker<p>This sample demonstrates how an application can communicate with a 2*90c8c64dSAndroid Build Coastguard Workercloud-based service and synchronize its data with data stored locally in a 3*90c8c64dSAndroid Build Coastguard Workercontent provider. The sample uses two related parts of the Android framework 4*90c8c64dSAndroid Build Coastguard Worker— the account manager and the synchronization manager (through a sync 5*90c8c64dSAndroid Build Coastguard Workeradapter). It also demonstrates how to provide users the ability to create 6*90c8c64dSAndroid Build Coastguard Workerand edit synchronized contacts using a custom editor.</p> 7*90c8c64dSAndroid Build Coastguard Worker 8*90c8c64dSAndroid Build Coastguard Worker<p> The <a 9*90c8c64dSAndroid Build Coastguard Workerhref="../../../reference/android/accounts/AccountManager.html">account 10*90c8c64dSAndroid Build Coastguard Workermanager</a> allows sharing of credentials across multiple applications and 11*90c8c64dSAndroid Build Coastguard Workerservices. Users enter the credentials for each account only once — 12*90c8c64dSAndroid Build Coastguard Workerapplications with the <code>USE_CREDENTIALS</code> permission can then query the 13*90c8c64dSAndroid Build Coastguard Workeraccount manager to obtain an auth token for the account. An authenticator (a 14*90c8c64dSAndroid Build Coastguard Workerpluggable component of account manager) requests credentials from the user, 15*90c8c64dSAndroid Build Coastguard Workervalidates them with an authentication server running in the cloud, and then 16*90c8c64dSAndroid Build Coastguard Workerstores them to the account manager. This sample demonstrates how to write an 17*90c8c64dSAndroid Build Coastguard Workerauthenticator for your service by extending the new <code><a 18*90c8c64dSAndroid Build Coastguard Workerhref="../../../reference/android/accounts/AbstractAccountAuthenticator.html"> 19*90c8c64dSAndroid Build Coastguard WorkerAbstractAccountAuthenticator</a></code> abstract class. </p> 20*90c8c64dSAndroid Build Coastguard Worker 21*90c8c64dSAndroid Build Coastguard Worker<p>The sync adapter (essential to the synchronization service) declares the 22*90c8c64dSAndroid Build Coastguard Workeraccount type and ContentProvider authority to the sync manager. This sample 23*90c8c64dSAndroid Build Coastguard Workerdemosntrates how to write your own sync adapters by extending the <code><a 24*90c8c64dSAndroid Build Coastguard Workerhref="../../../reference/android/content/AbstractThreadedSyncAdapter.html"> 25*90c8c64dSAndroid Build Coastguard WorkerAbstractThreadedSyncAdapter</a></code> abstract class and implementing the 26*90c8c64dSAndroid Build Coastguard Worker<code>onPerformSync()</code> method, which gets called whenever the sync manager 27*90c8c64dSAndroid Build Coastguard Workerissues a sync operation for that sync adapter. </p> 28*90c8c64dSAndroid Build Coastguard Worker 29*90c8c64dSAndroid Build Coastguard Worker<p class="note"><strong>Update:</strong> This sample has been updated for Android 4.0 to 30*90c8c64dSAndroid Build Coastguard Workerdemonstrate new features, including: syncing and viewing contact groups, handling the "invite" 31*90c8c64dSAndroid Build Coastguard Workerintent, and a few other improvements.</p> 32*90c8c64dSAndroid Build Coastguard Worker 33*90c8c64dSAndroid Build Coastguard Worker<p> The cloud-based service for this sample application is running at: </p> 34*90c8c64dSAndroid Build Coastguard Worker<p style="margin-left:2em;">http://samplesyncadapter2.appspot.com/</p> 35*90c8c64dSAndroid Build Coastguard Worker 36*90c8c64dSAndroid Build Coastguard Worker<p>When you install this sample application, a new syncable "SampleSyncAdapter" 37*90c8c64dSAndroid Build Coastguard Workeraccount will be added to your phone's account manager. You can go to "Settings | 38*90c8c64dSAndroid Build Coastguard WorkerAccounts & Sync" to view the account and change its sync settings. </p> 39*90c8c64dSAndroid Build Coastguard Worker 40*90c8c64dSAndroid Build Coastguard Worker<img alt="Screenshot 1" src="../images/SampleSyncAdapter1.png" /> 41*90c8c64dSAndroid Build Coastguard Worker<img alt="Screenshot 2" src="../images/SampleSyncAdapter2.png" /> 42*90c8c64dSAndroid Build Coastguard Worker<img alt="Screenshot 3" src="../images/SampleSyncAdapter3.png" /> 43