读书人

想要读取log信息但是总是读不到。写

发布时间: 2013-08-04 18:26:16 作者: rapoo

想要读取log信息,但是总是读不到。写了个service implements runnable 想要读取log信息,但是总是读不到,大大们帮我看看哪里出问题了
写了个service implements runnable
想要读取log信息,但是总是读不到,大大们帮我看看哪里出问题了。。想要读取log信息,但是总是读不到。写了个service implements runnable 想要读取log信息,但是总是读不到,大大们帮小弟我看看哪里出有关问题了

public void run() {
// TODO Auto-generated method stub
System.out.println("the function run()");
Process pro = null;
try {
Runtime.getRuntime().exec("logcat -d");
pro = Runtime.getRuntime().exec(new String[] { "logcat", "*:I" });
//pro = Runtime.getRuntime().exec("logcat");
} catch (IOException e) {
e.printStackTrace();
}
BufferedReader br= new BufferedReader(new InputStreamReader(pro.getInputStream()));
String line = null;
while (isCatchLog) {
try {
while ((line = br.readLine()) != null) {
String temp = logContent.toString();
logContent.delete(0, logContent.length());
logContent.append(line);
logContent.append("\n");
logContent.append(temp);
// 发送log内容
sendLogContent(logContent.toString());
Thread.yield();


System.out.println(logContent.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}

android java
[解决办法]
 Runtime.getRuntime().exec("logcat -d");             pro = Runtime.getRuntime().exec(new String[] { "logcat", "*:I" }); 

这个应该只要一个就行了啊

读书人网 >Android

热点推荐