0

I am trying to obtain logcat output within a simple Android program using the following:

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);
      }

Unfortunately, bufferedReader.readline() always returns null.

What is the problem?

4

1 回答 1

1

看来我需要向 AndroidManifest.xml 文件添加以下权限:

    <uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />

这对我有用。

于 2013-05-08T00:16:36.097 回答