Skip to content Skip to sidebar Skip to footer

How To Programmatically Read Logcat In Real Time?

I have a service that would like to read data from logcat, from the start of the service (i.e. discarding logcat data prior to service start), monitoring the logcat data in real ti

Solution 1:

OK, turns out I missed out the -s parameter in logcat, which filters the logcat output.

Solution 2:

I'd recommend taking a look at the question and answers posted in this SO post. I'm not on the machine that I have studio installed on so I can't try this out right now. To help us answer your question, could you give some more information on the problem you are having? When you say that the approach that you have "doesn't work" what do you mean? Does the value of 'log' not change? Is an exception thrown? Are the logs given, but unfiltered?

Also, what you are trying to do may not work on an unrooted device. As this SO post/answer explains you no longer have access to the logs of other applications, only to those of your own application. This means that your service can only read the logs of the application that it is a part of on an unrooted device.

Post a Comment for "How To Programmatically Read Logcat In Real Time?"