开发者

How to disable network connectivity dynamically for a process?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜