mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
  1. Main page
  2. dev
  3. Main content

Handling Offline Capability and Data Sync in an Android* App – Part 2

2017-06-18 100hotness 0likes 0comments

Download PDF

https://software.intel.com/en-us/articles/handling-offline-capability-and-data-sync-in-an-android-app-part-2

Abstract

Mobile apps that rely on backend servers for their data needs should provide seamless offline capability. To provide this capability, apps must implement a data sync mechanism that takes connection availability, authentication, and battery usage, among other things, in to account. In Part 1, we discussed how to leverage the Android sync adapter framework to implement these features in a sample restaurant app, mainly using content provider. In this part we will explain the remaining pieces, the sync adapter and authenticator. We will also look at how to use Google cloud messaging (GCM) notifications to trigger the data sync with a backend server.

Contents

Abstract
Overview
Data Sync Strategy for Restaurant Sample App – Little Chef
Sync Adapter Implementation
Authenticator Implementation
Configuring and Triggering the Sync
About the Author

Overview

If you haven’t already read Part 1, please refer to the following link:

https://software.intel.com/en-us/articles/handling-offline-capability-and-data-sync-in-an-android-app-part-1

Part 1 covers the integration of content provider with our sample app, which uses local SQLite database.

Though the content provider is optional for sync adapter, it abstracts the data model from other parts of the app and provides a well-defined API for integrating with other components of Android framework (for example, loaders).

To fully integrate Android sync adapter framework into our sample app, we need to implement the following pieces: sync adapter, a sync service that links the sync adapter with Android sync framework, authenticator, and an authenticator service to bridge the sync adapter framework and authenticator.

For the authenticator we will use a dummy account for demo purposes.

Data Sync Strategy for Restaurant Sample App – Little Chef

As we discussed in previous articles, “Little Chef” is a sample restaurant app (Figure 1) with several features including menu content, loyalty club, and location-based services among others. The app uses a backend server REST API to get the latest menu content and updates. The backend database can be updated using a web frontend. The server can then send GCM notifications for data sync as required.

A Restaurant Sample App Little Chef
Figure 1: A Restaurant Sample App - Little Chef

When the restaurant manager updates

Tag: Nothing
Last updated:2017-06-18

mikebai

This person is a lazy dog and has left nothing

Like
< Last article
Next article >

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang