0

我正在使用此代码检索 logcat 消息并将它们编译到下面的数组列表(日志)中:

try {
        process = Runtime.getRuntime().exec(new String[] {"logcat", "-d"});
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
    try {

        while ((line = bufferedReader.readLine()) != null){
            System.out.println(line);
            log.add(line);
            }
        }
        bufferedReader.close();
        }
    catch (IOException e) {}

当我真正看到插入列表的内容时(通过打印'line'),我得到了两个不同的东西:

药片:

D/UsbDeviceManager(  208): updateUsbNotification mConnected = true, mConnected = true, mCurrentFunctions = mtp,adb, mUsbNotificationId = 0

电话:

06-14 00:45:14.090  1687  3676 D *PJSIP_ANDROID*: Expires: 3600

为什么设备之间的 logcat 格式不同?我可以让平板电脑看起来像手机吗?

4

1 回答 1

1

您是否尝试过设置显式 logcat 格式?

  -v <format>     Sets the log print format, where <format> is one of:

              brief process tag thread raw time threadtime long
于 2013-06-13T17:55:23.723 回答