'How to check android mobile network mode setting state "Always on" or "Auto" or "Always off" programmatically?
I need to get mobile network setting state in WearOS: "Always on" or "Auto" or "Always off".
Exactly need to differentiate these states in code
maybe there is a way through ConnectivityManager
or TelephonyManager
or Settings.Secure
?
I've also checked that in system logs we have:
PhoneDataStore: putInt(mobile_networks_radio_power_key, 1) -> Always on
PhoneDataStore: putInt(mobile_networks_radio_power_key, 2) -> Always off
PhoneDataStore: putInt(mobile_networks_radio_power_key, 0) -> Auto
RadioModemPreference: onPreferenceClicked() key = RADIO_MODEM_ALLWAYS_ON
RadioModemPreference: onPreferenceClicked() key = RADIO_MODEM_ALLWAYS_OFF
RadioModemPreference: onPreferenceClicked() key = RADIO_MODEM_AUTO
Maybe there is a way to access PhoneDataStore from apps?
Solution 1:[1]
Settings.System.getInt(contentResolver, "clockwork_cell_auto_setting") // OFF = 0; ON = 1
Settings.Global.getInt(contentResolver, "cell_on") // OFF = 0; ON = 1
cell_on | clockwork_cell_auto_setting | |
---|---|---|
Always off | 0 | 0 |
Always on | 1 | 0 |
Auto | 1 or maybe? 0 | 1 |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alexey Kolosov |