App competition has been heated, control of their own Android app traffic can give users a good user experience Oh, give the user a reason not to uninstall.How does Android perform traffic analysis? Good tcpdump Wireshark these two tools.1, tcpdump the command line mode, its command format is:tcpdump [-ADEFLNNOPQSTVX]
There are 3 places in the Linux system to save the traffic statistics files, for Android system also applies:(1) Under/proc/net/dev, you can view the incoming and outgoing traffic of each network interface (equivalent to adb shell Cat/proc/pid/net/dev,adbshell cat/sys/class/net/wlan0/statistics/rx _bytes)(2) Under/sys/
Android obtains mobile phone traffic usage
The software traffic usage data is stored in the/proc/uid_stat/uid (User ID)/file below
/Proc/uid_stat/uid/tcp_send upload traffic/Proc/uid_stat/uid/tcp_rcv download traffic
The key code is as follows:
// 1. Obtain a package
uid)//Gets the number of bytes sent for a network UIDFinally the Android Development network reminds developers again that the Trafficstats class works on the firmware of Android 2.2 API level 8.1 Android has a trafficstats class that can be directly obtainedTotal accepted
Friends who often surf the internet will be more worried about the amount of traffic they use every month, although the operator can query the flow of usage, of course, you can also use the mobile phone with the flow monitoring or some mobile phone software to understand the approximate flow of the use of the situation, so that we can use the flow of each month in our grasp.
Note: The following methods are local software monitoring values, f
Requirement: count the number of Wi-Fi/2G/3G/4G traffic
Issue:
1. How to Determine 2G/3G/4G
The system source code TelephonyManager class provides methods, but only hidden, so you can refer to the source code
Ii. How to make statistics
The TrafficStats class is provided after Android 2.2 for traffic statistics. For more information, see the manual.
Here I used
internal network that is connected to the system or from the system, and the packet travels to another external system, the packet is passed to the OUTPUT chain. Similarly, packets originating from an external system and going to an external system are passed to the FORWARD chain.Next, compare the header information of the packet with each rule in the chain to which it was passed, to see if it exactly matches a rule. If the packet matches a rule, the
(InvocationTargetException e) {
E.printstacktrace ();
}
}
/*** Mobile network Switches */ Privatevoidsetmobiledataenabled (contextcontext,booleanenabled) { connectivitymanagerconmgr= (Connectivitymanager) context.getsystemservice ( Context.connectivity_service);class This error has been found for half a day ~ ~ ~ didn't find a way to solve [HTML] view Plaincopyprint?
java.lang.NoSuchMethodException:setMobileDataEnabled [Boolea
Android Network-determine the Network status (Network connection, change, and determine 2G/3G/4G)
Currently, most apps need to obtain data from the network. Therefore, it is inevitable to access the network. Before accessing the
To make a good Android application, it is essential to use the network communication technology, it is difficult to imagine a software without network interaction can eventually develop much success. So let's take a look at how web interactions are implemented in general Android apps, and here's an example of a Boook o
Most apps now need to get data from the Web. So access to the network is inevitable. But before we go back to the network, we should make a state judgment of the network first. In fact, before accessing the network we have to do some state judgment, corresponding to some state judgment to do processing, not directly us
Original address: http://android.xsoftlab.net/training/basics/network-ops/managing.htmlThis lesson will learn how to have finer-grained control over the use of network resources. If your application often performs a large number of network operations, the program should provide a setting so that the user can control the data habits of the app, such as how often t
Original address: http://blog.csdn.net/forlong401/article/details/23538951http://www.trinea.cn/android/android-network-sniffer/This method is mainly about how to carry out network data capture on Android and iphone , for example,
(original data format), JSON (JSON format), XML (XML format) is very convenient.Stop network Monitoring, remove the proxy settings of WiFi, or fiddler quit after the phone on the screen Oh.If you need to restore the phone without password status, the Android side can be set by the system-security-trusted credentials-users, click on the certificate to delete or clear the credentials to remove all user certi
connection that was the result of failing over from a disconnected network,Then the failover_connection Boolean extra is set to true.For a loss of connectivity,If the connectivity manager is attempting to connect (or has already connected) to another network,The networkinfo for the new network is also passed as an extra.This lets any receivers of the broadcast k
Statement: This method is only used to determine the default data network, that is, the data network that needs to pay X yuan each month to obtain the Internet traffic of xx m. No WiFi, etc.
Step 1: add the permission to read the network status of the mobile phone
Step 2: Check whether the default data
traffic. However, the steps described in XML and JSON are always indispensable.
I feel that using this method to transmit data is the most tedious process of encapsulating and parsing XML each time. Can I bypass this most complicated process?
As shown in, if you can call a Network API and directly send the book object to the server, the entire network interacti
First, Introduction
Now in the Android application, the inevitable use of the picture, if every time the picture is loaded from the network to pull back, this not only very time-consuming user traffic, and the picture load will be very slow, user experience is very bad. So an application of the image caching strategy is very important. In general, the caching st
developing web pages in the Android system, HTTP Communication processing, URL address processing, webKit, Wi-Fi, Bluetooth, mail, and RSS applications. At the end of this book, four large-scale integrated instances are used to describe the basic process of developing the network video player system, RSS reader system, mail system, and traffic monitoring system,
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.