0

I am new to android and I am trying to build an app that reads speech signal values using a thread and display the value on the ui using handler. Recording thread that reads the values and sends message to handler.Handler for the recording thread message

I actually need the textview to update every 3 seconds , but the value of the variable value is getting updated very fast. In the code containing recording thread, I want to send the message after every 3 seconds(as can be seen, the while loop runs for 3 seconds). but I am unable to do that . Please help!!

  • have a look at [this](http://stackoverflow.com/questions/21726055/android-loop-part-of-the-code-every-5-seconds) – Manohar Mar 14 '17 at 05:32

2 Answers2

1

You can use the Handler class:

final Handler handler = new Handler();
handler.post(new Runnable(){

    @Override
    public void run(){
        // change your text here
        handler.postDelayed(this, 3*1000);
    }
});
Komal12
  • 3,340
  • 4
  • 16
  • 25
0

Use handler or TextView:

textView.postDelay(new Runnable());
zxbin
  • 656
  • 5
  • 13