I'm making an application, which must show me in logs which applications I start on device. I use logcat ActivityManager:I *:S
and it doing this well.. at some devices and emulators.
But at some devices it has strange behavior - everything I see in log is repetition of:
02-18 16:32:09.132: D/LockApp(4082): --------- beginning of /dev/log/main
Code snippet:
Process process = null;
try {
process = Runtime.getRuntime().exec("logcat -c");
process = null;
process = Runtime.getRuntime().exec("logcat ActivityManager:I *:S");
br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
line = br.readLine();
while( line != null && !this.isInterrupted()){
Log.d(Tag, "Start LockApp loop");
Log.d(Tag, line);
}
} catch (IOException e) {
Log.d(Tag, e.toString());
}
And I have android.permission.READ_LOGS
in Manifest
I`m doing it in Android 4.1 and 4.2