handler, I want to run periodically
Try the below
m_Handler = new Handler();
mRunnable = new Runnable(){
@Override
public void run() {
if(count == 0){
// do something
count = 1;
}
else if (count==1){
// do something
count = 0;
}
m_Handler.postDelayed(mRunnable, 3000);// move this inside the run method
}
};
mRunnable.run(); // missing
Also check this
Android Thread for a timer
You should go for Timer and TimerTask in that case. Below is a small example:
//Declare the timer
Timer t = new Timer();
//Set the schedule function and rate
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
//Called each time when 1000 milliseconds (1 second) (the period parameter)
//put your code here
}
},
//Set how long before to start calling the TimerTask (in milliseconds)
0,
//Set the amount of time between each execution (in milliseconds)
3000);
Hope this is what you needed.