My app is data intensive and I want to provide users the comfort of turning o开发者_如何学Pythonn/off WIFI only data usage.
My application makes use of the network connectivity all over and also the ads do too. How can I globally for the app process limit the data connectivity type to only WIFI?
If wifi is enabled, then the phone uses it instead of cell networks.
You can check if it is enabled using WifiManager
: http://developer.android.com/reference/android/net/wifi/WifiManager.html#isWifiEnabled%28%29 and decide based on that boolean wether you use the network or not.
You can also check getConnectionInfo ()
to make sure that a connection is active: http://developer.android.com/reference/android/net/wifi/WifiInfo.html
精彩评论