0

I have three informative screens like Facebook blogs in my application. Application works Online and Offline. User can see the data offline.the data is Cached in Database.

When data is added/updated/deleted to server from active users.

The problem is, I want to update all other active application users with new data without affecting their works and in short time. In short, want to update it in background. How I can achieve this?

I have tried below solutions but had some issues:

1. After registration fetching all data from server and store in Database for Offline use.

Problem with this solution: Always showing progress bar for caching data impact bad user experience. user will get irritated.

2. Implemented background processing GCM push notification.(Means without displaying push notification to user process it in background)

Problem with this solution: If user blocks notification then the application never get synchronized with new data added/updated/deleted on server.

Prags
  • 2,457
  • 2
  • 21
  • 38
Anil Ravsaheb Ghodake
  • 1,587
  • 2
  • 27
  • 45
  • 1
    Best way is to use a SyncAdapter (albeit caveats of lot's of boilerplate code). SyncAdapter works with the Android OS to optimize syncs and can sync both data TO the backend and FROM the backend, so you can cache the latest state when the SyncAdapter is triggered to update. You could also use the SyncAdapter to run the sync "now" as well to (suppose) a user needs a refresh. – Lucas Crawford Jul 30 '16 at 19:15
  • @Lucas Crawford first time I heard about SycAdapter.I also check the android developer site but I am not able to understand this concept.So,Is there any explanation tutorial/example you know. – Anil Ravsaheb Ghodake Aug 01 '16 at 05:32
  • 1
    In the FCM case why would your users turn off notifications if they want your app to sync? – Arthur Thompson Aug 01 '16 at 18:41
  • @ArthurThompson Is FCM used for background process notification? because I have used GCM. – Anil Ravsaheb Ghodake Aug 01 '16 at 18:50
  • @ArthurThompson If I use FCM and user blocks notification will the FCM also get blocked or not? – Anil Ravsaheb Ghodake Aug 01 '16 at 18:54
  • If the user blocks notifications for your application then both FCM and GCM messages will not be able to be processed. – Arthur Thompson Aug 01 '16 at 21:53
  • @ArthurThompson that is the actual problem I have with app data syncing using GCM. Is there any other solution you know? – Anil Ravsaheb Ghodake Aug 07 '16 at 12:26
  • 1
    I don't think this is a problem, if your user turns off notifications for your app then you should inform them that this will prevent background syncing and thus syncing will be done at launch and they will see a spinner. Give the user the choice. – Arthur Thompson Aug 07 '16 at 13:38

1 Answers1

0

Well, if the data is in Json, you can use Retrofit for data fetching, its amazingly fast.

After registration fetching all data from server and store in Database for Offline use.

Solution: After the user is registered show the Progress for the first time while your getting the data and updating the database, after that display the data from database and keep updating the data in the background.

Or you can simply make a ProgressBar of height 2dp near ActionBar to show the user while data updates in the background and user can interact with the current data available from database.

You can use MaterialProgressBar or make your own.

halfer
  • 19,824
  • 17
  • 99
  • 186
Atiq
  • 14,435
  • 6
  • 54
  • 69