写了个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

解决方案 »

  1.   

     Runtime.getRuntime().exec("logcat -d");             pro = Runtime.getRuntime().exec(new String[] { "logcat", "*:I" }); 
    这个应该只要一个就行了啊
      

  2.   

    这个我是这么想的,先获得全部的log(logcat -d)然后筛选出info信息 ("logcat", "*:I")我用system.out.println(br.readline())  输出为空啊,我觉得是没有获取到log信息。