Android-based traffic statistics and android-based traffic statistics

Source: Internet
Author: User

Android-based traffic statistics and android-based traffic statistics

// --------------------- Traffic statistics -------------------------------- try {PackageManager pm = getPackageManager (); ApplicationInfo ai = pm. getApplicationInfo ("com. orimuse. app ", PackageManager. GET_ACTIVITIES); // com. orimuse. the app is the package name Log of its own application. d ("!! ","!! "+ Ai. uid); long received = TrafficStats. getUidRxBytes (ai. uid); // obtain the number of accepted bytes of a network UID long sent = TrafficStats. getUidTxBytes (ai. uid); // get the number of bytes sent by a network UID Toast. makeText (mContext, "orimuse cumulative receipt of data" + received ED/1024 + "KB", Toast. LENGTH_SHORT ). show (); Toast. makeText (mContext, "orimuse cumulative sending Byte" + sent/1024 + "KB", Toast. LENGTH_SHORT ). show ();} catch (NameNotFoundException e) {e. printStackTrace ();}//-----------------------------------------------------

Q: Is there any interface for android traffic statistics?

The post will be returned, and the landlord has worked hard.
 
Android has its own traffic statistics. Can I directly call the interface to obtain this?

Obtain the system service. obtain the information from the information service. view the original post about the address book.>

Please accept

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.