Reputation: 12544
I have this code , and I want to run Log.d every 1000 milis , but It only run once .
seekView.postDelayed(new Runnable() {
public void run() {
Log.d("WWWW", "www");
}
}, 1000);
creating handler , timer , ... only run once like this , where is my problem ?
Upvotes: 3
Views: 4003
Reputation: 9791
Use for repeat:
...
class YourTimeTask extends TimerTask {
public void run() {
....
}
}
...
new Timer().scheduleAtFixedRate(new YourTimerTask(), after, interval);
...
Upvotes: 3
Reputation: 68177
To keep it running continuously at an interval of 1 second, you need to call postDelayed as nested in your Run method again. See the example below:
seekView.postDelayed(new Runnable() {
public void run() {
Log.d("WWWW", "www");
//calling postdelayed again
seekView.postDelayed(this, 1000); //added this line
}
}, 1000);
doing so will keep it calling it self at an interval of 1 second.
Upvotes: 11