I simply want to update a TextView periodically by a service. Let\'s say the TextView should display the time and update itself every 30 seconds. Could\'t you guys tell me how I
Handler h = new Handler();
int delay = 30000; //milliseconds
h.postDelayed(new Runnable(){
public void run(){
editText.setText(java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime())+"");
h.postDelayed(this, delay);
}
}, delay);
In onCreate() //updating every 30 seconds
Handler handler =new Handler();
final Runnable r = new Runnable() {
public void run() {
handler.postDelayed(this, 30000);
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
edittextId.setText(mydate);
}
};
handler.postDelayed(r, 0000);