I want my app to check whether "Data network mode" or "Mobile data" is enabled, even if it is not currently active. In other words I need to check whether the app will potentially incur mobile data charges, even if it the phone is currently connected through WiFi.
By googling I have found the following code which checks whether "Mobile data" is "active".
ConnectivityManager cm =
(ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isMobile = activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE;
The problem with this code is that if WiFi is active the Mobile data is not reported as active even if it is switched to on.
Can the code be modified to determine whether mobile data is "enabled" and therefore potentially active, rather than as with this code whether it is the currently active connection mode?