Is there an API to determine if mobile data limits have been reached?

Asked 2 years ago, Updated 2 years ago, 42 views

Mobile data usage is over and restricted
Is it possible to determine whether mobile data usage is over and restricted by Android API?

android

2022-09-30 19:17

1 Answers

When I checked the source of the framework for the configuration application and restriction dialog display
I think I can refer to it by using isOverLimit(), a NetworkPolicy class that can be retrieved from NetworkPolicyManager.getNetworkPolicy().

Both the NetworkPolicyManager class and the NetworkPolicy class are public, but because of the @hide class, it is not a public API, and the hurdle seems to be high.
I think it is possible to use it by using reflection, but it is not a legitimate method, so I don't think the Android version will guarantee it to work.


2022-09-30 19:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.