android - getting network/data usage via adb -


i looking figure out how data application sending , receiving on android handset running 2.3 through adb/adb shell

the closest thread have found this

tracking application's network statistics (netstats) using adb

but doesn't work me.

ideally see network stats given application , know how wipe/reset these stats if needed.

any ideas?

you can use trafficstats class calculate internet usage different applications installed in device if using adb/adb shell isn't necessary requirement

       final packagemanager pm = getpackagemanager();         // list of installed apps.         list<applicationinfo> packages = pm                 .getinstalledapplications(packagemanager.get_meta_data);          // loop through list of installed packages , see if selected         // app in list         (applicationinfo packageinfo : packages) {          // uid selected app         uid = packageinfo.uid;           //internet usage particular app(sent , received)          long recived = trafficstats.getuidrxbytes(uid);         long send = trafficstats.getuidtxbytes(uid);           } 

internet usage application :

receivedmbs = (double) trafficstats.getuidrxbytes(android.os.process                 .myuid()) / (1024 * 1024); sentmbs = (double) trafficstats.getuidtxbytes(android.os.process                 .myuid()) / (1024 * 1024); 

related links :

trafficstats api android , calculation of daily data usage

traffic stats example

hope helps .


Comments