1

我在 ICS (4.0.3) 上有一个应用程序,它使用带有 -vtime 选项的 logcat。它使用以下代码读取 logcat:

try {
  Process process = Runtime.getRuntime().exec("logcat -vtime -d");
  BufferedReader bufferedReader = new BufferedReader(
  new InputStreamReader(process.getInputStream()));
  String line = "";

  while ((line = bufferedReader.readLine()) != null) {
      ... my stuff with this line...
} 
catch (IOException e) {
}

我在清单文件中使用“android.permission.READ_CALL_LOG”和“android.permission.READ_LOGS”,并且我设法拥有完整的logcat。

当我将此代码与 JellyBean (4.1.1) 一起使用时,我的缓冲区仅捕获我的应用程序 logcat 而不是完整的设备 logcat。

我怎样才能拥有这个完整的 logcat?是另一种许可吗?

4

1 回答 1

0

JellyBean (4.1.1) does not grant 3rd party applications to access a full system logcat. Application can only see own logging rows. I think you don't need to give READ_LOGS permission in AndroidManifest.xml anymore(any app can logcat own lines).

https://groups.google.com/forum/?fromgroups=#!topic/android-developers/6U4A5irWang

If you still want to read a full logcat you need to rooted device and give superuser access to your application.

于 2013-03-05T16:38:46.930 回答