send a broadcast from logcat

喜欢而已 提交于 2019-12-11 20:23:52

问题


how can i send broadcast from logcat result like send broadcast if activity start (it taged with activity manager)

like if browser start the logcat will display that :

09-10 09:47:04.020: I/ActivityManager(2707): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.browser/.BrowserActivity } from pid 2880

there are app in market do like what is ask for which called

LogCatNotifier

https://play.google.com/store/apps/details?id=RabiSoft.LogCatNotifier&hl=en


回答1:


If what you're asking is how do you know when to send a broadcast when something specific is logged, you should have a Service monitor the device's logs, and when it encounters a log that you want to send a broadcast about, then you should send a broadcast.

You can learn about reading from logs programmatically here

EDIT: If I'm not mistaken, in JellyBean it's no longer possible to read logs from any app besides your own.



来源:https://stackoverflow.com/questions/12346866/send-a-broadcast-from-logcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!