Git Product home page Git Product logo

syncadapter_example's Introduction

SyncAdapter Example

This is an example following the google developer training post which covers how to implement a SyncAdapter as well as the other components needed to plug a sync adapter into the framework.

While it is possible to implement network sync code, using this framework allows developers to take advantage of several features:

  • Plug-in architecture
  • Automated execution
  • Automated network checking
  • Improved battery performance
  • Account management and authentication

It should be noted that sync adapters run asynchronously. Data is transferred regularly and efficiently, but not instantaneously. If one needs to do real-time data transfer, another approach such as AsyncTask or IntentService should be used.

SyncAdapters can be triggered into performing sync through a few approaches.

  • When server data changes
  • When content provider data changes
  • Periodically
  • On demand

Server data changes recognized/captured using GCM then running a call to ContentResolver.requestSync(), While content provider changes can be caught with content observers that trigger sync with the same call.

Periodical sync can take place by making an addPeriodicSync() call to the contentResolver or using an Alarm then triggering the sync with requestSync() call.

On demand can be made any time by simply calling ContentResolver.requestSync() and passing the expected information as bundle extras. Documentation suggests not performing on demand sync.

This example makes sync requests on demand during the activities onResume() method.

syncadapter_example's People

Contributors

iammck avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.