android - Detect new data when call is given to webservice -


i have app, in refreshing app in particular amount of time.

each time call given webservice , messages in database loaded listview.

its done follows:

public class messages extends activity {       protected handler handler = new handler();      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_messages);          intent intent = getintent();          string message = intent.getstringextra(mainactivity.extra_message);         string id = intent.getstringextra(mainactivity.extra_id);         string[] lst = null;         listview lm=(listview)findviewbyid(r.id.listview1);         textview tv = (textview)findviewbyid(r.id.textview1);          tv.settext("welcome " + message);          handler.postdelayed(new updatetask(),750);     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.messages, menu);         return true;     }      class updatetask implements runnable {          @override         public void run() {             // todo auto-generated method stub              setcontentview(r.layout.activity_messages);              intent intent = getintent();              string message = intent.getstringextra(mainactivity.extra_message);             string id = intent.getstringextra(mainactivity.extra_id);             string[] lst = null;             listview lm=(listview)findviewbyid(r.id.listview1);             textview tv = (textview)findviewbyid(r.id.textview1);              tv.settext("welcome " + message);              callsoap cs=new callsoap();              lst=cs.getmessage(id);              arrayadapter<string> adpt = new arrayadapter<string>(messages.this, android.r.layout.simple_list_item_1,lst);              lm.setadapter(adpt);              handler.postdelayed(this, 500);         }     } } 

now, unable detect (highlight) new messages in app, because each time when call given webservice retrieves messages.

how should detect new message(or can data in listview ) particular interval of time.

please me.

add 1 field(i.e. status) in database. , when call service , return message database status need change 1 (0 means still webservice not fetch, 1 means fetch @ android side). after new records inserted service fetch records status have 0.

i hope you.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -