how can I call function every 10 sec?
Use a combination of Timer
and TimerTask
like this:
int delay = 0; // delay for 0 sec.
int period = 10000; // repeat every 10 sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask()
{
public void run()
{
//Call function
}
}, delay, period);
Also make sure to use runOnUiThread()
if you want to modify the UI.
Do it like this:
final Handler ha=new Handler();
ha.postDelayed(new Runnable() {
@Override
public void run() {
//call function
ha.postDelayed(this, 10000);
}
}, 10000);