how can I call function every 10 sec?

android, android-handler

Solution

Do it like this:

final Handler ha=new Handler();
ha.postDelayed(new Runnable() {

    @Override
    public void run() {
        //call function

        ha.postDelayed(this, 10000);
    }
}, 10000);

Problem

I want make an app that call a function for example every 10 sec. I wrote my code like this: ``` Handler ha=new Handler(); ha.postDelayed(new Runnable() { @Override public void run() { //call function } }, 10000); ``` But my function call just one time in 10 sec after compile this code. How can I fix it?

Original source