Thanks for looking into my question.
I am a beginner in android development and currently i am trying to make chat app which uses socket and node js.
I use
Hy Karan.. you are going in the right way mate. The only thing that is missing is the small snippet of code. Error here is that you set adapter in working thread. You can update views only from main thread. You have to move the portion of the background task that updates the ui onto the main thread. Just replace the code on:
@Override
public void on(String event, IOAcknowledge ack, Object... args)
with:
@Override
public void on(String event, IOAcknowledge ack, Object... args) {
// TODO Auto-generated method stub
if(event.equals("new_client_message")){
Log.v("SocketIO", "new_client_message" + " " + args[0]);
rohan = args[0].toString();
System.out.println("admin" + " : " + " " + rohan);
runOnUiThread(new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
mListData.add("Admin" + " : " + " " + rohan);
mListData.notifyDataSetChanged();
lvList.setSelection(mListData.getCount() -1);
}
});
}
here "new_client_message" is trigger from the server.. just replace with yours. For example in you case "new_message" is the trigger from your app to the server. Sorry for not a professional word but i hope it will help. Cheers