How to get the logs of other applications?

I want to read logs from other applications and filter them, so when a specific keyword is logged, my application performs a specific task.

I found several methods for reading logs, but from my testing I could only get application logs.

This is the method that I originally tried to use

try { Process process = Runtime.getRuntime().exec("logcat -d"); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream())); StringBuilder log=new StringBuilder(); String line = ""; while ((line = bufferedReader.readLine()) != null) { log.append(line); } TextView tv = (TextView)findViewById(R.id.textView1); tv.setText(log.toString()); } catch (IOException e) {} 

But it looks like it only reads the logs of my application.

+6
source share
1 answer

You can read the logs of all applications if the device is rooted.

If you want to read short device logs, then this will help you. However, you need to set targetSdk to 16.

+4
source

All Articles