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.

Answers


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.


Need Your Help

How to make sequence diagram for sign up

uml visio sequence-diagram visual-paradigm

I'm preparing the sequence diagram for a project. I started with the sign up operation.

Strange Oracle error with Hibernate and CLOBs

hibernate oracle10g

I've run into the following issue, which seems to be a pretty common one. The exception is Cannot update entity: [...] nested exception is java.sql.BatchUpdateException: ORA-24816: Expanded non LON...