Public voidGetData () {//Packagemanager Package Management classPackagemanager Packagemanager = brownseractivity. This. Getpackagemanager (); intPackageuid = 0; BigDecimal Numrx=NewBigDecimal ("0"); BigDecimal NUMTX=NewBigDecimal ("0"); /*** Cycle through the package name of all apps and the current app's package name to match operations to save the obtained UID to a temporary variable*/ /*For (ApplicationInfo info:packageManager.getInstalledApplications (0)) {int uid = INFO.UID; String PackageName = info.packagename; if (Packagename.indexof ("Iassistant") >-1) {packageuid = UID; Break } }*/ //gets the UID of the current appPackageuid =Android.os.Process.myUid (); //The Trafficstats class obtains data related to traffic based on the UID of the application LongRx = trafficstats.getuidrxbytes (PACKAGEUID);//Total Receive Volume Longtx = Trafficstats.getuidtxbytes (PACKAGEUID);//Total Send Volume floatJustload =0f; LOG.I ("Scott", "This application this time the total receive volume:" +Rx); LOG.I ("Scott", "the total number of times this application is sent:" +tx); if(Rx > 0) {Numrx=bytetom (RX); Justload= Numrx.floatvalue ()-InitData; InitData=Numrx.floatvalue (); } if(Tx > 0) {numtx=Bytetom (TX); } //Toast.maketext (Brownseractivity.this, "Total Received:" +numrx.floatvalue () + "M",//toast.length_short). Show ();Toast.maketext (brownseractivity. This, "This receive Volume:" + justload + "M", Toast.length_short). Show (); LOG.I ("Scott", "Total received after conversion to (m):" +Numrx.floatvalue ()); LOG.I ("Scott", "total send amount after conversion to (m):" +Numtx.floatvalue ()); } /*** bytes converted to M*/ PrivateBigDecimal Bytetom (Longvalue) {BigDecimal result=NewBigDecimal (long.tostring (value)); Result= Result.divide (NewBigDecimal ("1024.0")). Divide (NewBigDecimal ("1024.0")); returnresult; }