How to check only Wifi data usage in Android?
Is there an API or example available where i can check only Wifi data usage? This is available in ICS onwards devices under settings. But how to do it through it. I want to get some ideas on that front.
Another thing to check here is that i only want to monitor the data usage if i am connected to 1 particular wifi network only, i guess that would not be a problem if i am able to get the data usage for Wifi?
Please see i am also aware of TrafficStats API but that does not solve my purpose.
You can still use the TrafficStats APIs in this way to get Wifi usage:
int mobileTx = TrafficStats.getMobileTxBytes(); int mobileRx = TrafficStats.getMobileRxBytes(); int wifiTx = TrafficStats.getTotalTxBytes() - mobileTx; int wifiRx = TrafficStats.getTotalRxBytes() - mobileRx;
This will return the total amount of Wifi data usage since the previous device boot.