Android的网络统计数据 [英] Android network stats

查看:112
本文介绍了Android的网络统计数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建一个应用程序,获取网络活动/统计数据,而作为后台进程运行的?或者只是使听交通特定端口上的应用程序?

Is it possible to create a application that gets network activity / statistics while running as a background process? Or just make a application that listen to traffic on a specific port?

谢谢
中号

推荐答案

这也许碰运气。但我最常用的设备有/ proc文件系统。你应该能够得到你需要走出的/ proc /净/项之一的统计信息。例如,要获得一个netstat的:

It maybe hit and miss. But most devices I have used have the /proc file system. You should be able to get the stats you need out of one of the /proc/net/ entries. For example to get a 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
}

这篇关于Android的网络统计数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆