java - Can I access internet data used by user from Internet data Usage -


trafficstats class provides total data since boot can directly access internet data usage android

e.g call history can directly fetched call log. possible internet data internet data usage.

and how internet data usage on basic of application ?

so know cannot directly internet data usage android fetch call history record form call log can data form trafficstats class since boot

to internet data on application basic here simple code using packagemanager package name of corresponding app , using applicationinfo can find detail of application information

 final packagemanager pm = context.getpackagemanager();         // list of installed apps.         list<applicationinfo> packages = pm.getinstalledapplications(0);         (applicationinfo packageinfo : packages) {             // uid selected app             uid = packageinfo.uid;             string package_name = packageinfo.packagename;           log.d("mypackagename",package_name+"");             applicationinfo app = null;             try {                 app = pm.getapplicationinfo(package_name, 0);             } catch (packagemanager.namenotfoundexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }             string name = (string) pm.getapplicationlabel(app);             drawable icon = pm.getapplicationicon(app);             // internet usage particular app(sent , received)             double received = (double) trafficstats.getuidrxbytes(uid)                     / (1024 * 1024);             double send = (double) trafficstats.getuidtxbytes(uid)                     / (1024 * 1024);             double totalab = received + send;} 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -