[Android Memory] How to view an app's current traffic in an Android system

Source: Internet
Author: User

Reprinted from: http://blog.sina.com.cn/s/blog_628cc2b70101dbyy.html

First, view principle: The network traffic data of an application is saved in/proc/uid_stat/$UID/TCP_RCV file of the system.

Second, step:

(1) Get PID of the current application: View the current app's process ID through the PS command, such as the Application Center is Ps|grep AppStore, get a value of 10928

(2) Obtain the UID of the current application: Enter the directory/proc/$PID, view the status file UID value, such as the view of the Application Center, CD/PROC/10928,CAT status, get the value of 10006

(3) View the cumulative value of the app's received data: Go to the catalog/proc/uid_stat/$UID and view TCP_RCV values, such as how the app Center is viewed, Cd/proc/uid_stat/10006,cat TCP_RCV.

(4) View the current application per second of traffic values: through a second interval to print two times TCP_RCV value of the calculation of the difference obtained, the value obtained by automated means is more accurate.

[Android Memory] How to view an app's current traffic in an Android system

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.