android timer example – Android Timer Tutorial

android timer example

android timer example

android timer example is complete tutorial to work with android timer.

final Handler h = new Handler();

//========================================
// Creation of Runnable Object
//========================================
final Runnable r = new Runnable() {

@Override
public void run() {
// TODO Auto-generated method stub

Toast.makeText(getApplicationContext(), “Wow..Its working”, Toast.LENGTH_SHORT).show();
}
};

//======================================
//Creation of Timer Object (Need to pass TimerTask())
//======================================
t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {

@Override
public void run() {

//use handler post event and pass runnable object
h.post(r);

}
}, 1000, 5000);

Check more android tutorial here

Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative