Android提供的獲取流量的方法

2021-06-19 05:57:18 字數 677 閱讀 3952

trafficstats.getmobilerxbytes();  //獲取通過mobile連線收到的位元組總數,不包含wifi  

trafficstats.getmobilerxpackets();  //獲取mobile連線收到的資料報總數,不包含wifi   

trafficstats.getmobiletxbytes();  //mobile傳送的總位元組數   

trafficstats.getmobiletxpackets();  //mobile傳送的總資料報數   

trafficstats.gettotalrxbytes();  //獲取總的接受位元組數,包含mobile和wifi等   

trafficstats.gettotalrxpackets(); //總的接受資料報數,包含mobile和wifi等   

trafficstats.gettotaltxbytes();  //總的傳送位元組數,包含mobile和wifi等   

trafficstats.gettotaltxpackets();  //傳送的總資料報數,包含mobile和wifi等   

trafficstats.getuidrxbytes(int uid);  //獲取某個網路uid的接受位元組數   

trafficstats.getuidtxbytes(int uid); //獲取某個網路uid的傳送位元組數

Android 定時獲取上下行流量資料

使用service監聽上下行流量資料 老樣子,直接上東西 public class flowservice extends service override public void oncreate override public int onstartcommand intent intent,i...

手機流量資訊的獲取

獲取手機流量的工具類 市面上的一些流量統計軟體,一般是定義乙個資料庫,手機關機的時候會有乙個廣播事件 android.intent.action.action shutdown 監聽到這個廣播事件,然後存到資料庫。public class trafficutil 獲取手機2g 3g產生的總流量 re...

android流量監測的實現原理

2.2版本以前的,系統的流量資訊都存放在proc net dev 或者proc self net dev 檔案下,讀取檔案然後對其進行解析就行了。讀取某乙個應用的流量,則讀取proc uid stat uid tcp rcv檔案進行解析 據說模擬器下是沒有這個目錄檔案的 對於android流量統計來...