我在做一个应用程序,它必须告诉我在我开始对设备的应用程序日志。我用 logcat的ActivityManager:我*:•
,它这样做很好..一些设备和仿真
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):---------开始的/ dev /日志/主
code片断:
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());
}
和我有 android.permission.READ_LOGS
在清单
我真的做在Android的4.1和4.2
I`m doing it in Android 4.1 and 4.2
这是什么的logcat -c
>这将清除(刷新)整个日志并退出。
What is this logcat -c
> this will Clears (flushes) the entire log and exits.
有只 V,D,I,W,E&安培; WTF
:-)六型logcat的分类
There are only V,D,I,W,E & WTF
:-) Six type of logcat category
将其更改为调用Runtime.getRuntime()EXEC(logcat的-e);
链接在这里:
编辑: 有一个在读的果冻豆的问题 链接这里
There is an problem in Reading in jelly bean link here
READ_LOGS上糖豆(安卓4.1)的权限将不会被授予了正常的应用程序。
READ_LOGS permission on Jelly Beans (Android 4.1) will not be granted anymore to normal apps.
应用程序只允许读自己的日志。
Apps are only allow to read their own logs.
有关详情,请信息
您可以尝试实现一个功能,授予自己READ_LOGS权限与用户root权限的设备。
You could try to implement a function to grant yourself READ_LOGS permission with for users with rooted devices.
上一篇:没有启动活动中活动中