1
我想顯示應用程序日誌。 在終端上我使用了這個命令:adb logcat -s brief *:V | grep「pid」 它顯示我的應用程序日誌。在android中執行管道命令?
pid表示在logcat表中顯示的應用程序pid。
public static String logProc()
{
String value = "";
try
{
String cmd[] = {"logcat","-s","brief","*:V","|","grep",
android.os.Process.myPid()+""};
Process p = Runtime.getRuntime().exec(cmd,null, null);
BufferedReader reader = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null)
{
value += line + "\n";
line = reader.readLine();
}
p.waitFor();
}
catch (IOException e1)
{
e1.printStackTrace();
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return value;
}
這是什麼問題? –
@Deepali:問題是它沒有顯示任何輸出。它的連續顯示如下日誌06-14 15:16:43.104:I/dalvikvm-heap(591):爲881344字節的分配增加堆(碎片情況)到4.535MB 06-14 15:16:43.154:D/dalvikvm(591):GC_FOR_MALLOC在37ms中釋放了3個對象/ 587632字節 – Deepali
如何以編程方式在android中執行「adb logcat -s brief *:V | grep」pid「」命令 – Deepali