如何在Android中捕获调制解调器无线电日志

问题描述 投票:10回答:2

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

提前致谢。

编辑

我发现Read logcat programmatically within application用于捕获logcat日志的应用程序

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

谢谢

android android-logcat android-log
2个回答
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


0
投票

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

adb logcat -b radio

© www.soinside.com 2019 - 2024. All rights reserved.