2

I can't get full info from netstat, from not rooted device.

If i use

Process process = Runtime.getRuntime().exec("netstat -n");

with "-n" or other doesn't work. how i read stream from netstat

process.getOutputStream().close();
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readline()) != null) {
// Parse line for required info
}
reader.close();

How can i get pid or process name with using netstat (or something other to monitor network activity) without root

I test it in android 6.0 and get only:

Proto Recv-Q Send-Q Local Address Foreign Address State click to see

1 Answers1

1

You must get input stream from your process object and then read process output line by line until null line is received.

Proto Recv-Q Send-Q Local Address Foreign Address State

it's just the first line of netstat output.

For example: https://stackoverflow.com/a/13506836/4449456

Community
  • 1
  • 1
Alan Kazbekov
  • 1,105
  • 2
  • 12
  • 31