如何开发离线优先的本机Android应用程序 [英] How to develop an offline-first native Android app

查看:216
本文介绍了如何开发离线优先的本机Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个本机Android应用程序(随后是iOS和网络),用户可以在其中协同创建相册.

We are developing a native Android app (iOS and web to follow) where users can collaboratively create an album.

当设备无法与服务器连接时,我们希望获得尽可能无缝的体验. Hoodie博客中提到的内容,但Hoodie现在适用于Web和iOS,我们正在寻找Android.

We want as seamless as possible experience when device is not able to connect with server. Something like mentioned in this Hoodie blog but Hoodie is right now for Web and iOS and we are looking for Android right now.

问题

在客户端维护相册,朋友,图片(URL/本地,而非位图)的数据. 能够在以后解决冲突的情况下将脱机创建/更新操作同步到服务器.

Maintaining data of albums, friends, pictures (URL/local, not Bitmap) on Client side. Being able to sync offline create/update operations to server at later time, with conflict resolution.

当前研究

  1. HTTPResponseCache :缺点:仅缓存一次被命中的请求.另外,还需要其他系统来处理创建/更新操作.
  2. App42 Microsoft Sync Framework工具包:不确定它在Android上的运行效果如何
  3. PouchDB
  4. Superbus :解决了一部分问题
  1. HTTPResponseCache: Cons: Caches only requests which have been hit once. Plus need different system to handle create/update actions.
  2. App42, Kinvey: Backend-as-a-service; Cons: We want to have own backend.
  3. Microsoft Sync Framework Toolkit: Not sure how well it works with Android
  4. PouchDB
  5. Superbus: Solves a part of the problem

自定义

在Android上的SQLite和服务器上的MySQL中维护数据 使用 Android同步适配器进行同步. 但是,这可能很耗时,并且在启动时会出现错误.

Maintain data in SQLite on Android and MySQL on server Sync using Android Sync Adapter. However, this can be time consuming and have bugs in starting.

该如何解决?

推荐答案

我目前正在研究一个项目,即使用户处于脱机状态,我们也需要跟踪交付情况并验证交付情况.我使用的方法是利用此简单内容提供程序.我检查是否有互联网,是否没有互联网.它将数据存储到提供者,并更改数据库中需要更改的所有内容,并使我的用户相信他(她)已完成订单.而且我有一个 Google Cloud Messaging 可以为您的用户节省大量电池寿命.那里可能会有更好的选择.但是,根据我对 Android 的了解,这就是我的小帮助.

I am working on a project at the moment, and we need to track deliveries and verify deliveries even when user is offline. The approach I use is to make use of this ContentProvider plugin Simple Content Provider. And I check if there's internet or not, and if there's none. It stores the data to the provider and change whatever needs to be changed in the DATABASE and make my user believe he or she has completed the order. And I've a SyncAdapter waiting for the internet to come on. And, I've a push service too to refresh the database once there's a change in the database. Having an understanding of Google Cloud Messaging would save your user a lot of battery life. There might be better options out there. But, from my little experience with Android that's how my little help could be.

这篇关于如何开发离线优先的本机Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆