0

In my application, I want to update my UI continuously after 2 seconds. Which is the most suitable method to update.

  1. Timer
  2. Async task or anything else?
Developer
  • 67
  • 10

1 Answers1

2

Define a Runnable:

private Runnable mRunnable = new Runnable() {
    @Override
    public void run() {
       //Update to your UI
    }
};

Inside your continuous thread:

runOnUiThread(mRunnable);
Rajan Kali
  • 12,627
  • 3
  • 25
  • 37