I need to somehow monitor the LogCat log, meaning that while my service is running I need to read the LogCat for new entries. At this moment I know only how to retrieve once the Log:
Process mLogcatProc = null;
BufferedReader reader = null;
try
{
mLogcatProc = Runtime.getRuntime().exec(new String[]
{"logcat", "-d", "ActivityManager:I *:S" });
reader = new BufferedReader(new InputStreamReader
(mLogcatProc.getInputStream()));
String line;
final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator");
while ((line = reader.readLine()) != null)
{
log.append(line);
log.append(separator);
}
If I remove the -d option it will not exit but also it will not either work. So how can I modify the bellow code in order to continuously read new entries from LogCat?