问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/46025444/how-to-check-mobile-data-usage-programmatically