I've tried time&timertask, handler&runnables, nothing makes my function be called after certain time. Please, help me get rid of this.
when = System.currentTimeMillis();
t1 = new Timer();
tt = new TimerTask(){@Override public void run(){ systemClick();}};
t1.scheduleAtFixedRate(tt, when+interval, interval);
And this one:
final Handler myHandler = new Handler();
Runnable runnableforadd = new Runnable()
{
public void run()
{
systemClick();
myHandler.postDelayed(this, interval);
}
};
myHandler.postDelayed(runnableforadd, when + interval);
Both the first and the second I execute in onCreate(). systemClick()
doesn't get called even for a one time in deed (I've put Toast in there). I don't understand in Threads well.
systemClick
- is a function, where system performs click of my button - myButton.performClick()
is called there (and other functions as well).
How can I solve this?
Thanks