我需要从Android中的调制解调器无线电日志中捕获一些信息,但我不知道如何捕获它。我搜索了很多,但没有找到。由于我需要有关android中的baseband
的一些信息,我发现必须捕获调制解调器日志。
提前致谢。
编辑
我发现Read logcat programmatically within application用于捕获logcat
日志的应用程序
但因为它是adb log adb logcat -b radio
我不知道如何捕获ADB登录应用程序。正如我在一条评论中看到的那样,我怀疑是否有可能。
谢谢
尝试这样的事情:
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
在adb设备连接后,在终端或控制台上使用以下命令。
adb logcat -b radio