How to check mobile data usage programmatically?
Asked Answered
P

1

14

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?

Psalter answered 3/9, 2017 at 16:19 Comment(5)
@ModularSynth no, it's not. sorry didn't explained well. I need to do it via code in an app of coursePsalter
Guys this question isn't off topic at all. He explained it so why all this downvotes?Soandso
developer.android.com/reference/android/net/TrafficStats.htmlClarendon
Asking for a tutorial is actually very off-topic, here.Doubletime
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.Clarendon
C
12

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.

Clarendon answered 5/9, 2017 at 16:32 Comment(1)
In my Galaxy note 10 (2022), I get 0 from this.Toothsome

© 2022 - 2024 — McMap. All rights reserved.