I am trying to bind to a cellular network on demand (wifi is still running). I have the following code:
override fun onAvailable(network: Network) {
Android exposes a property through developer options that allows you keep mobile data always active. Enabling this flag allows you to switch between wifi and cellular data connections and make successful network requests on the requested network immediately.
This flag is also defined as a global setting.
Settings.Global.MOBILE_DATA_ALWAYS_ON
https://github.com/aosp-mirror/platform_frameworks_base/blob/e80b45506501815061b079dcb10bf87443bd385d/services/core/java/com/android/server/ConnectivityService.java#L951