websockets and sync adapter in android - android

I'm designing an application for getting some data from a web service, like a REST API and showing it to the user:
I was thinking about using the Sync Adapter with Content Provider API:
the Sync Adapter handles the data flow between the local DB and remote DB.
the content provider API loads the data into the UI.
My question is that the remote application, if, has a server push support (using Socket.IO or so), how should I design the app to exploit this feature? because as far as I understand, when the SyncAdapter will run is determined by SyncManager. So I can't ensure that the sync is done only when the server pushes. I wanted to know if this is possible, even without running the application in the foreground or background. i.e., only with the sync adapter running.
thanks in advance for any replies.
PS: I'm just starting to design android apps, so forgive me/correct me if I'm wrong.
Follow up:
I'm not interested in the Cloud messaging APIs (like GCM). I wanted to keep the data private if the user wishes to.

If your application will be running for a while you don't really want to keep a constant connection open to a server since that will eat a lot of batteries.
It sounds like you're looking for this:
http://developer.android.com/google/gcm/index.html
Using gcm your app can get a notification when there's an update on your server.

Related

Sync data between Android App, Web and Desktop application

Currently, I have an App that sends data to web server.
But, if website sends data to the server, my App does not receive any data from the server.
I want to create an app like Evernote where I don't have to refresh the app to receive data from the server.
So when I sends data from mobile, it has to sync with all other devices.
How do I implement it?? Which method is best for android?
Is GCM the only way to do it?
We need more information regarding what you have tried implementing for us to provide a better solution since your issue is about code implementation.
You may check Firebase Realtime Database as this seems perfect for your situation because with Firebase, "data are synced across all clients in realtime, and remains available when your app goes offline". Since you are using Android, you can check this document: Set up Firebase Realtime Database for Android.

Android 2-way sync-ing approach

I'm developing an app which list the shops around my area by category. I have a REST API where the results would be returned in paginated mode (page=2, limit=20 etc) and users will need to login to the app in order to view the listing.
I'm thinking to incorporate offline 2 way sync into my app. The moment when user logs in for the first time he has to be connected to the internet and subsequently once he has logged in he should be able to proceed straight to the main screen eventhough the app is offline.
User also has the ability to post a review offline in which I suppose we should cache the post request in the DB and listen to network state changed event? Once there's a network then query everything in the cache and send to the server.
I understand how this can be achieved at high level but I'm still new to Android and not exposed to the popular libraries out there. Just wondering is there any library that is already doing all the magic for me?
I stumble across Sync Adapter and Content Provider but it seems like they are quite complicated to a beginner. Is there a simpler library that can achieve similar results?
Also from my understanding the way how it works would be.. there will be a service that periodically poll server for changes - and fetch when there's any then store into SQLite. On poll it will also retrieve client changes and send to server. When user views listing the app will retrieve from SQLite instead making request to the server - there is no direct interfacing between the App and server. Can anyone verify if my understanding is correct?

Android react to DB changes

I'm building an Android application that consumes a RESTful API.
When I make a http request to the server I get a JSON response that I can then parse and display appropriately on the screen. So far so good.
Now as my application is going to have multiple users I'd like to refresh this information to all users when any of them changes it.
I know that you can accomplish something similar using AngularJS but I'm not sure you can use that on Android.
My only other idea is to make http requests from the mobile app every X period of time, say 30 seconds (but this is not very elegant and would consume lots of network resources).
Any ideas of how to solve this? Thanks!
PD: I used Laravel to build my REST API.
Either you will use a background thread to check your server for changes every once in a while(basically polling from server), or you use push notifications (whenever something changes on your server side, server will push the data that changed to you). Preferably push should be the way you choose cause it is both user and battery friendly. Also eases your server load.
In android, push notifications implemented mostly by using GCM. You can read rest through here http://developer.android.com/google/gcm/index.html
For a local network, you can use MQTT. There is an excellent blog post about it here http://dalelane.co.uk/blog/?p=1599 .

android app for different end user

This may be as simple as for your knowledge. But I don't know how to search and get.
Now I've developed one android app with sqlite. Using this app, from my device only I can create and do insert and update the data as admin and user. I want to develop my app should be accessed by many user from different mobile and they should be update their detail. What are all the things I should know and How to do ?
Please help me out.
I am assuming you are new to this. Since your app is already completed and I am assuming it is working I would suggest reading up on the following things and you will need to make a few decisions also.
I believe that the LAMP stack would be best for you unless you have .NET experience, you should go read up on:
MySQL
pHp
RESTful web services and what they do here and here
How to AsyncTask works
How to run backgroud services
MySQL will be used to store your data in the cloud
pHp will be the server side language with which you access and query your database and control the data being written to it
RESTful will be the way you implement your pHp functions and how you will return data and process requests to your service
AsyncTask will allow you to run background processes in Android, it is important to remember never to run a long running action in the main UI thread, thus we use AsyncTask to accomplish the multithreading
I suggest background services since you already have a functioning app with a local sql database, the background services can then be used to keep your app synced with the database in the cloud, that way when a new user accesses your app on a different device that he/she normally uses his/her data will be available on the new device.

How android sqlite databse will update in android market?

Currently I am working on android e-commerce project, I am using sqlite database to store data.
I need to update my database each and every time. My question is if i upload my app in android market, how can i update my database every day.I know about android versioning concept if i update version of the my apk , how people who are using my app will know that my app is updated.
Please give me a clear idea on this . Thanks in advance.
I have a better solution for this problem. It will be better if you host a web service that will serve the update information. You can do it for free. GoogleAppEngine provides this feature. Serve JSON file from web, parse it in you application. Each time your app launches, write code to check for update information. OR check once in week or some other strategy. This might be tougher way of doing but you can provide more efficient and flexibility through this.
if i upload my app in android market, how can i update my database
every day
You can do this stuff using Web services call to your data server .
now you might have a question in your mind about users devices battery ,
if you continually call those web services your device battery gonna loose lot.
or
if you call this web service in some specific interval then app user might miss the actuate time when data has loaded already .
so i suggest to use GCM for could push notification .
How its works in your project :
When you data will update on server , then there should be one script on server side which send message to GCM server with some required field of identification of that application package
when you device receive that message using your GCM receiver you may need to update your database as you did so far .

Categories

Resources