并非所有的Andr​​oid时,被的logcat编程读取显示的数据 [英] Not all data shown when Android logcat is read programatically

查看:157
本文介绍了并非所有的Andr​​oid时,被的logcat编程读取显示的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的问题,我试图让logcat的数据编程。许可也被加入到清单文件:

I have such a problem, I try to get data from logcat programatically. permission has also been added to manifest file:

<uses-permission android:name="android.permission.READ_LOGS"/>

code:

Code:

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Process process = Runtime.getRuntime().exec("logcat ActivityManager:I *:S");
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

                String line;
                while ((line = bufferedReader.readLine()) != null) {
                    reactOnString(line);
                }
            } catch (IOException e) {
            }
        }
    }).start();

不过,我看不到在其他应用程序的启动。我在等待一个像下面这样的字符串,但它们不会出现。

However I cannot see when other apps are launched. I am waiting for strings like the one below but they do not appear.

2260-2566/system_process                 I/ActivityManager: Start proc com.android.email for activity com.android.email/.activity.MessageCompose: pid=6460 uid=10011 gids={50011, 3003, 1015, 1023, 1028}

P.S。这code运行服务。

P.S. This code is run in service.

推荐答案

我对你不好的消息:作为JB的,READ_LOGS不只是工作,因为它没有了:

I have bad news for you: as of JB, READ_LOGS don't just work as it did anymore:

<一个href="https://groups.google.com/forum/?fromgroups#!topic/android-developers/6U4A5irWang">https://groups.google.com/forum/?fromgroups#!topic/android-developers/6U4A5irWang

(滚动戴安娜Hackborn,一个Android Develper的职位)和这个视频:

(scroll to the post of Dianne Hackborn, an Android Develper) and this video:

谷歌I / O 2012 - 十件事游戏开发者应该知道

(22:47)。

不过他还没有被记录(的 READ_LOGS 许可,不报告本)和尚未混乱的一个来源。您只能访问自己的日志,现在,好消息是,你就不必再为它要求的权限的(如果你的目标定位是糖豆,就是这样......)。

However his has not been yet documented (the READ_LOGS permission doesn't report this) and is yet a source of confusion. You can only access your own logs now, and the good news is, you don't need to request permissions for it anymore (if your are targetting Jelly Beans, that's it...).

我想这是一个妥协的Andr​​oid开发团队走上prevent恶意应用从刺探用户,也许获得敏感信息(我不会赌每一个应用程序开发者清除它发布之前自己Log.d语句)。

I guess it's a compromise the Android Dev team took to prevent malicious app from spying on the user, perhaps getting sensitive information (I wouldn't bet every app developer cleans it's own Log.d statements before release).

希望这有助于

这篇关于并非所有的Andr​​oid时,被的logcat编程读取显示的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆