写了个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();
}
}androidjava
想要读取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();
}
}androidjava
解决方案 »
- Unable to instantiate activity ComponentInfo 初学Android,请问下面有甚么区别
- RelativeLayout不能绑pressed="true"?
- android中实现百度地图,在线等
- android 系统notification图片如何引用?
- 在android上做那些特效UI能用什么类/组件/控件?效果怎么样?想收集参考一下大家的想法。
- 如何简便的获取android组件所在的TabHost?
- 游戏中 不同屏幕的适配问题
- PullToRefresh里嵌入viewPager轮播图片
- Android VideoView.getCurrentPosition()获取的值不为0。为什么下次还是从0开始播放呢?
- android6.0 MediaRecorder录像,想通过setOutputFile(sender.getFileDescriptor()),获取流,启动失败
- 贡献海量Android经典学习教程和Android应用级源码
- 在一个textview上叠加一个button
这个应该只要一个就行了啊