title: Problem with dynamically updating text view
body: <p>I have implemented the logs and they are being displayed on the screen. But even after creating the thread, the logs are not being dynamically updated on the screen. New logs should be appended after one second. While the user stays on the screen, the logs should keep displaying on the screen but it is not happening. The thread that I have created works fine as I have tested it with a count variable. But with logs, it does not seem to work.</p>
  
  <p>Help me out, I am stuck here.</p>
  
  <pre><code>package com.example.logreader;
  
  import androidx.appcompat.app.AppCompatActivity;
  import android.os.Bundle;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.util.Timer;
  import java.util.TimerTask;
  import android.app.Activity;
  import android.os.Bundle;
  import android.os.Handler; 
  import android.text.method.ScrollingMovementMethod;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
  private int mInterval = 100; // 5 seconds by default, can be changed later
          private Handler mHandler;
          int count;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          TextView tv = (TextView)findViewById(R.id.textView);
          Thread t=new Thread(){
  
  
              @Override
              public void run(){
  
                  while(!isInterrupted()){
  
                      try {
                          Thread.sleep(1000);  //1000ms = 1 sec
  
                          runOnUiThread(new Runnable() {
  
                              @Override
                              public void run() {
                                  try {
                                      Process process = Runtime.getRuntime().exec("logcat -d");
                                      BufferedReader bufferedReader = new BufferedReader(
                                              new InputStreamReader(process.getInputStream()));
  
                                      StringBuilder log=new StringBuilder();
                                      String line = "";
                                      while ((line = bufferedReader.readLine()) != null) {
                                          log.append(line);
                                      }
                                      tv.setText(log.toString());
                                      tv.setMovementMethod(new ScrollingMovementMethod());
  
                                  } catch (IOException e) {
                                  }
  
                              }
                          });
  
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
  
                  }
              }
          };
  
          t.start();
  
      }
      }
  </code></pre>