如何从android中的log cat读取Activity名称?

时间:2011-11-14 10:30:46

标签: android

我们如何在Android中从logcat读取活动名称? 我使用了一些代码,但没有获得我发布的Activity名称。

String baseCommand = "logcat -d 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.e("This is Camera open log",""+log);
        log.append(line); // here readLine() returns null
    }
}
catch (IOException e1)
{
    e1.printStackTrace();
}

有人可以建议一个解决方案吗?

1 个答案:

答案 0 :(得分:1)

同一命令适用于从you can extract activity name from the tag "Activity Manager" which last appeared.

获取adb logcat 中的活动管理器信息