Home | History | Annotate | Download | only in sync-adapters

Lines Matching full:adapter

1 page.title=Creating a Sync Adapter
13 >Create the Sync Adapter Class</a>
16 <a href="#CreateSyncAdapterService">Bind the Sync Adapter to the Framework</a>
23 <a href="#CreateSyncAdapterMetadata">Add the Sync Adapter Metadata File</a>
26 <a href="#DeclareSyncAdapterManifest">Declare the Sync Adapter in the Manifest</a>
53 The sync adapter component in your app encapsulates the code for the tasks that transfer
55 your app, the sync adapter framework runs the code in the sync adapter component. To add a
56 sync adapter component to your app, you need to add the following pieces:
59 Sync adapter class.
62 A class that wraps your data transfer code in an interface compatible with the sync adapter
69 A component that allows the sync adapter framework to run the code in your sync adapter
73 Sync adapter XML metadata file.
76 A file containing information about your sync adapter. The framework reads this file to
83 XML that declares the bound service and points to sync adapter-specific metadata.
89 <h2 id="CreateSyncAdapter">Create a Sync Adapter Class</h2>
91 In this part of the lesson you learn how to create the sync adapter class that encapsulates the
92 data transfer code. Creating the class includes extending the sync adapter base class, defining
96 <h3>Extend the base sync adapter class AbstractThreadedSyncAdapter</h3>
98 To create the sync adapter component, start by extending
100 constructors to run setup tasks each time your sync adapter component is created from
108 <strong>Note:</strong> The sync adapter framework is designed to work with sync adapter
109 components that are singleton instances. Instantiating the sync adapter component is covered
111 <a href="#CreateSyncAdapterService">Bind the Sync Adapter to the Framework</a>.
120 * app, using the Android sync adapter framework.
128 * Set up the sync adapter
140 * Set up the sync adapter. This form of the
159 The sync adapter component does not automatically do data transfer. Instead, it
160 encapsulates your data transfer code, so that the sync adapter framework can run the
166 To facilitate the transfer of data from your main app code to the sync adapter component,
167 the sync adapter framework calls
177 the sync adapter. If your server doesn't use accounts, you don't need to use the
185 adapter.
210 adapter framework.
219 * Specify the code you want to run in the sync adapter. The entire
220 * sync adapter runs in a background thread, so you don't have to set
248 sync adapter framework doesn't automatically connect to a server.
254 A sync adapter doesn't automate any data transfer tasks. If you want to download
265 A sync adapter doesn't automatically handle conflicts between data on the server and data
279 <strong>Note:</strong> The sync adapter framework runs
293 <h2 id="CreateSyncAdapterService">Bind the Sync Adapter to the Framework</h2>
295 You now have your data transfer code encapsulated in a sync adapter component, but you have
297 {@link android.app.Service} that passes a special Android binder object from the sync adapter
303 Instantiate your sync adapter component as a singleton in the
308 adapter framework queues up multiple executions of your sync adapter in response to triggers or
313 bound {@link android.app.Service}, instantiates your sync adapter component, and gets the
320 * sync adapter class, allowing the sync adapter framework to call
324 // Storage for an instance of the sync adapter
329 * Instantiate the sync adapter object.
334 * Create the sync adapter as a singleton.
335 * Set the sync adapter as syncable
346 * the sync adapter.
362 <strong>Note:</strong> To see a more detailed example of a bound service for a sync adapter,
367 The sync adapter framework requires each sync adapter to have an account type. You declared
384 // The authority for the sync adapter's content provider
403 * Create a new dummy account for the sync adapter
436 <h2 id="CreateSyncAdapterMetadata">Add the Sync Adapter Metadata File</h2>
438 To plug your sync adapter component into the framework, you need to provide the framework
440 the account type you've created for your sync adapter, declares a content provider authority
447 This XML file contains a single XML element <code>&lt;sync-adapter&gt;</code> that has the
464 If you're transferring data from a content provider to a server with your sync adapter, this
473 The account type required by the sync adapter framework. The value must be the same
487 Sets the visibility of the sync adapter's account type. By default, the
490 adapter invisible unless you have an account type or domain that's easily associated
492 control your sync adapter with a user interface in one of your app's activities.
505 Allows multiple instances of your sync adapter component to run at the same time.
514 Indicates to the sync adapter framework that it can run your sync adapter at any
516 adapter can run, set this flag to {@code false}, and then call
518 sync adapter. To learn more about running a sync adapter, see the lesson
519 <a href="running-sync-adapter.html">Running a Sync Adapter</a>
525 The following example shows the XML for a sync adapter that uses a single dummy account and
530 &lt;sync-adapter
540 <h2 id="DeclareSyncAdapterManifest">Declare the Sync Adapter in the Manifest</h2>
542 Once you've added the sync adapter component to your app, you have to request permissions
547 Since the sync adapter component runs code that transfers data between the network and the
549 to request permission to read and write sync adapter settings, so you can control the sync
550 adapter programmatically from other components in your app. You also need to request a
563 Allows the sync adapter code to access the Internet so that it can download or upload data
571 Allows your app to read the current sync adapter settings. For example, you need this
579 Allows your app to control sync adapter settings. You need this permission in order to
580 set periodic sync adapter runs using {@link android.content.ContentResolver#addPeriodicSync
583 running the sync adapter, see <a href="running-sync-adapter.html"
584 >Running A Sync Adapter</a>.
606 interact with your sync adapter, add the following XML to your app manifest as a child element
626 {@code android.content.SyncAdapter}, sent by the system to run the sync adapter. When the filter
640 element provides provides the name of the sync adapter metadata XML file you created previously.
643 attribute indicates that this metadata is for the sync adapter framework. The
648 You now have all of the components for your sync adapter. The next lesson shows you how to
649 tell the sync adapter framework to run your sync adapter, either in response to an event or on