Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check mobile data usage programmatically?

The question is pretty straight forward, How do I find out how much mobile data (in GB or MB) has the user used in the current month?

As it has been reported as off topic, I want to clarify that the data usage is supposed to be checked via code in an app.

Is there some code I can use to check for the users used data?

like image 201
Daniele C Avatar asked Sep 03 '17 16:09

Daniele C


People also ask

How do you keep track of GB usage?

Check Data Usage From an Android Device To check your current month's usage on your Android phone, go to Settings > Connections > Data Usage. The screen shows your billing period and the amount of cellular data you've used so far. You can also set a mobile data limit on this screen.


1 Answers

See: https://developer.android.com/reference/android/net/TrafficStats.html

Try:

Toast.makeText(this, android.net.TrafficStats.getMobileRxBytes()+"Bytes", Toast.LENGTH_SHORT).show();

getMobileRxBytes() Return number of bytes received across mobile networks since device boot.

like image 160
Mukesh M Avatar answered Sep 22 '22 21:09

Mukesh M