【发布时间】:2012-02-15 14:02:54
【问题描述】:
我需要以编程方式使用过滤器转储 logcat。我应用了 adb logcat -s "TAGNAME" 但应用程序只是“挂起”。有一个类似的线程但没有解决方案:Read filtered log cat(Programmatically)?
try {
Process process = Runtime.getRuntime().exec("logcat -s XXX");
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
StringBuilder log = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
log.append(line);
log.append(FragmentLog.LINE_SEPARATOR);
}
((TextView) tv).setText(log.toString());
} catch (IOException e) {
((TextView) tv).setText(R.string.default_blank);
}
【问题讨论】:
标签: android logcat android-logcat