How to check cellular data limit option is enabled or disabled in android 11 device?

180 views Asked by At

On the android 11 device, I want to check for the "data limit" option is enabled or disabled on the device those are running Android 11. Currently, I am using NetowrkPolicy, NetworkPolicyManager, NetworkTemplate classes. But those all are hidden APIs and now blocked or restricted in targeting device android 11. And code is below -

        if (networkPolicy.limitBytes == NetworkPolicy.LIMIT_DISABLED) {
           //currentlly data limit is not enabled on device
        } else {
            //currentlly data limit is enabled on device, so that we can calculate how much is remaining.
        }

I have already searched in for ConnectivityManager [Not provide much information related to my task]. I am guessing this may be currently in any setting package or not sure.

Note - I just want to check if the option is enabled or not on device those are targeting android 11.

Update - 1

I am not sure how this can be useful - KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG (Controls the cellular data limit), this says - If the user uses more than this amount of data in their billing cycle, as defined by KEY_MONTHLY_DATA_CYCLE_DAY_INT, cellular data will be turned off by the user's phone. If the value is set to DATA_CYCLE_THRESHOLD_DISABLED, the data limit will be disabled.

0

There are 0 answers