在 Android 应用程序中刷新 Logcat
Flush Logcat in androidapp
我不知道如何刷新我的应用程序中的 Logcat。下面的代码
将 Logcat 保存到文件中:(有效)
File File_logcat = new File(Environment.getExternalStorageDirectory(),
"log.txt");
try {
Runtime.getRuntime().exec(
"logcat -f " + File_logcat.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
保存后,我用以下命令刷新 Logcat:(这不起作用)
try {
Runtime.getRuntime().exec(
"logcat --clear"); //Also tested -c or -b all –c
} catch (IOException e) {
e.printStackTrace();
}
我在 developer.android.com 上搜索了一个解决方案,上面写着“logcat -b all –c”(甚至 –c)会刷新它,但 none 成功了.
我是不是漏掉了什么?
感谢@CommonsWare。
我刚刚发现这两个代码片段都可以在 root 移动设备上运行。所以好像不能乱刷。
我不知道如何刷新我的应用程序中的 Logcat。下面的代码
将 Logcat 保存到文件中:(有效)
File File_logcat = new File(Environment.getExternalStorageDirectory(),
"log.txt");
try {
Runtime.getRuntime().exec(
"logcat -f " + File_logcat.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
保存后,我用以下命令刷新 Logcat:(这不起作用)
try {
Runtime.getRuntime().exec(
"logcat --clear"); //Also tested -c or -b all –c
} catch (IOException e) {
e.printStackTrace();
}
我在 developer.android.com 上搜索了一个解决方案,上面写着“logcat -b all –c”(甚至 –c)会刷新它,但 none 成功了.
我是不是漏掉了什么?
感谢@CommonsWare。 我刚刚发现这两个代码片段都可以在 root 移动设备上运行。所以好像不能乱刷。