How Can I Check My Android App's Network Consumption?
Solution 1:
Android Studio 2.0 Introduce new Network
section in Android Monitor
which can help you with your problem.
Tx == Transmit Bytes Rx == Receive Bytes
Solution 2:
There are three ways...
You can view in Device/Emulator. Go to Setting -> Data usage, and find your application in the list
In Eclipse, select DDMS (perspective) -> Select your package from Devices (left side) -> Click on Network Statistics tab -> Click Start
As already answered, in Android Studio, go to Android Monitor (bottom tab) -> Network (tab) -> look for Tx (Transmit Data) / Rx (Receive Data)
Solution 3:
For view purposes, you can check it in the monitor as mentioned by MD.
To store, you can do that programmatically
intUID= android.os.Process.myUid();
rxBytes += getUidRxBytes(UID);
txBytes += getUidTxBytes(UID);
/**
* Read UID Rx Bytes
*
* @param uid
* @return rxBytes
*/public Long getUidRxBytes(int uid) {
BufferedReader reader;
LongrxBytes=0L;
try {
reader = newBufferedReader(newFileReader("/proc/uid_stat/" + uid
+ "/tcp_rcv"));
rxBytes = Long.parseLong(reader.readLine());
reader.close();
}
catch (FileNotFoundException e) {
rxBytes = TrafficStats.getUidRxBytes(uid);
//e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
return rxBytes;
}
/**
* Read UID Tx Bytes
*
* @param uid
* @return txBytes
*/public Long getUidTxBytes(int uid) {
BufferedReader reader;
LongtxBytes=0L;
try {
reader = newBufferedReader(newFileReader("/proc/uid_stat/" + uid
+ "/tcp_snd"));
txBytes = Long.parseLong(reader.readLine());
reader.close();
}
catch (FileNotFoundException e) {
txBytes = TrafficStats.getUidTxBytes(uid);
//e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
return txBytes;
}
}
Solution 4:
Have a look: Android Monitor.
In that there are many topics that you can monitor.
You will find Network Monitor.
Displaying a Running App in the Network Monitor:
Follow these steps:
- Connect a hardware device.
- Display Android Monitor.
- Click the Network tab.
- Open an app project and run it on the hardware device.
- To start the Network Monitor, click Pause Pause icon to deselect it.
Any network traffic begins to appear in the Network Monitor:
The Network Monitor adds up the amount of time it takes for the device to transmit and receive kilobytes of data. The y-axis is in kilobytes per second. The x-axis starts with seconds, and then minutes and seconds, and so on.
- To stop the Network Monitor, click Pause Pause icon again to select it.
Reference: Android Monitor
Post a Comment for "How Can I Check My Android App's Network Consumption?"