在我的android测试项目中,我只是阅读了logcat
使用adb command
喜欢,
public StringBuilder log=new StringBuilder();
public String line="";
public String temp="";
public void testSolo() throws Exception {
String baseCommand = "logcat -v time";
baseCommand += " ActivityManager:I "; // Info for my app
baseCommand += " *:S "; // Silence others
try {
Process logReaderProcess = Runtime.getRuntime().exec(baseCommand);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(logReaderProcess.getInputStream()));
while ((line =bufferedReader.readLine()) != null) {
log.append(line); // here readLine() returns null
}
}
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
但是,在这里string line
我总是得到空值,
而同样的事情总是在 android 中运行activity's onCreate()
。我不明白为什么会这样?
同样的事情在活动类中运行,而不是在 android 测试项目中。
我还在测试项目的
文件READ_LOGS
中 添加了 use -permission 。WRITE_EXTERNAL_STORAGE
manifest.xml
有没有人知道它是如何工作的或发生了什么?
提前致谢。