In my android test project, I simply read the logcat
using adb command
like,
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();
}
}
but, here in string line
I always get null value,
while the same thing always run in the android activity's onCreate()
.
I don't understand why this happen?
Same thing runs in activity class and not in the android test project.
I also add use -permission for READ_LOGS
and WRITE_EXTERNAL_STORAGE
in test project's
manifest.xml
file.
Is there anybody knows how it works or what happens?
Thanks in advance.
Try to add
to your manifest.