Android Network Statistics

Is it possible to create an application that receives network activity / statistics while running in the background? Or just make an application that listens for traffic on a specific port?

Thank you, m

+3
android
Oct 11 '10 at 6:53
source share
2 answers

It could be a miss. But most of the devices I used have the / proc file system. You should be able to get the necessary statistics from one of / proc / net / entries. For example, to get netstat:

Process proc = Runtime.getRuntime().exec(new String[] {"cat", "/proc/net/netstat"}); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { // parse netstat output here } 
+3
Oct 11 '10 at 11:08
source share

No need to run the command "cat / proc / net / netstat". Instead, a simpler approach can solve the problem.

 Process proc = Runtime.getRuntime().exec(new String[] {"netstat"}); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { // parse netstat output here } 
-one
Feb 16 '15 at 6:16
source share



All Articles