Android news feed - android

I need to display some data from the server via my RecyclerView. The problem is how to notify the application that new data is available in the server. I have seen in some applications where the top of the list has a button with text like "Show 5 new posts." After clicking on that button, the 5 new posts download from the server without downloading the entire list of data. How can I implement that same synchronization?

There are lots of ways to achieve synchronisation in android.
You can use SyncAdapter (Highly recommended).
You can use GCM, push to client if anything new comes up and act accordingly.
Further you can use Local Broadcast Listener to notify that view

I think this link will help you to understand the synchronization between android app and server - Sync data between Android App and webserver .

Related

Firebase: notify app uers when data in a json file changes

I have successfully built an android app for my WordPress blog. The app retrieves the list of posts from an online jSON file, parses it and populates RecyclerView with the data. The last bit of work is notifying the users when I post new content to blog and the JSON file changes.
Please, do you have any idea how I might achieve this?
You should use the push services on both ends (android and firebase).check firebase's docs for how to implement their service.
push services automatically notifies (or posts , you can do whatever you like when the event is fired) the users subscribed to the service.

Is there any android framework for sync data between local file and server?

In my app, user get data from server, then I save these data to local file of phone, so same data don't need to load from server again. If there are some new messages send to user, these data need to load from server.
I intended to do it myself, but it seems this functionality is not so simple as I imagined. I think this is a common functionality, is there any framework focus on it?
Please give me some guidance.
I recommend you read Sync Adapter
The sync adapter component in your app encapsulates the code for the
tasks that transfer data between the device and a server. Based on the
scheduling and triggers you provide in your app, the sync adapter
framework runs the code in the sync adapter component.

saving chats using chatadapter

I am using a custom chatadapter that I use to make a simple chat program with multiple user. However as soon as I leave the chat activity all the messages are gone. What would I have to do to save all the messages of that chat history and then put them back in the chat window when the user opens up the chat? The chats are in a listview. I am new to JAVA so I am not fully aware on how to go about this. If I understand correctly I would have to use SQL. Can anyone guide me as to the efficient way to do this? Thanks
Best thing to go about this is use SQLlite database. As chats volumes may be high and better to avoid service call to load huge data set. Also, local database required for handling network connect/disconnect(you might need to retry messages which are not being sent during network glitch).
You can take reference from Applozic's open source client repo.
If you intend to keep more than few messages and chats in your app, and access them efficiently, then yes - database would definitely be the good way to approach this problem.

Android auto refresh data from server

TLDR: I am wondering what is the best practice in android to do the following - when new data is stored in server side database inform and transfer data to android application ?
LONG STORY: I currently have server side application based on Node.js and MongoDB where I store my data in JSON format. Server (Node) exposes REST service which I call when I want add new data to database. I have another REST service which is called by android application client when refresh local data button is pressed. Everything is working like a charm, but I want to extend my android client application, so the data is transferred to application as soon as it comes to server. I have been looking at combination of:
AsyncTask(http://developer.android.com/reference/android/os/AsyncTask.html) and
BroadcastReciever (http://developer.android.com/reference/android/content/BroadcastReceiver.html).
But I am not sure if this is the right way to do it. Also I know I will have to make changes to my server side application, but this is not a problem.
So I am not looking for exact code how to do it, but for some advices what should I use.
http://en.wikipedia.org/wiki/Push_technology
http://en.wikipedia.org/wiki/Google_Cloud_Messaging
https://developers.google.com/cloud-messaging/
third one is the actual answer, but first ones have details

How to update the listView in android when the data is updated in server?

Well in my app, the data from the server is being pulled in Json format and then with costume adapter i'm updating the listview.
But when ever the new content is updated in server how to trigger my app to know that some new content is available now in server. So that app can pull from the server and update the listview.
Just thinking of using GCM, is it a right way ?
Any better idea ?
Push notification (GCM) is the easiest way to go forward for this task. Just fire one push when your server data updated, and on mobile side, when you get push notification at that time just call your Activity and just refresh your ListView (setting whole adapter again or calling notifyDatasetChanged()).

Categories

Resources