• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Problem with dynamically updating text view in android

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.

Help me out, I am stuck here.

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();      }     } 
Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]