11

我需要从android中的调制解调器无线电日志中捕获一些信息,但我不知道如何捕获它。我搜索了很多,但没有找到。由于我需要一些关于basebandandroid 的信息,我发现必须捕获调制解调器日志。

提前致谢。

编辑

我发现在应用程序中以编程方式读取 logcat以捕获应用程序中的logcat日志

但是因为它是 adb logadb logcat -b radio我不知道如何在应用程序中捕获 ADB 日志。正如我在一条评论中看到的那样,我怀疑这是否可能。

谢谢

4

2 回答 2

3

adb 设备连接后,在终端或控制台上使用以下命令。

adb logcat -b 收音机

于 2019-03-20T04:55:54.570 回答
1

尝试这样的事情:

try {
    Runtime rt = Runtime.getRuntime();
    //here you can add your params
    String[] commands = {"logcat"};
    Process proc = rt.exec(commands);

    BufferedReader stdInput = new BufferedReader(new
            InputStreamReader(proc.getInputStream()));

    BufferedReader stdError = new BufferedReader(new
            InputStreamReader(proc.getErrorStream()));

    String s;
    while ((s = stdInput.readLine()) != null) {
        //here is your logcat
        Log.i("logcat", s);
    }

    while ((s = stdError.readLine()) != null) {
        Log.e("logcat", s);
    }
 } catch (IOException e) {
    e.printStackTrace();
}

请记住,您可能需要 root 才能阅读 logcat。

UPD:工作示例 - https://github.com/sssemil/SampleLogcatApp

于 2016-09-08T12:14:01.103 回答