是否有可能迫使一个Android应用程序只使用移动无线连接(3G / 4G /等),禁止使用的WiFi?
Is it possible to force an Android application to use only the mobile radio connection (3g/4g/etc), disallowing the use of WiFi?
我想,我想用一个HIPRI连接:(例如:WIFI打开,使用HIPRI 3G): 的http://groups.google.com/group/android-developers/browse_thread/thread/d41f85505484d29b
I think I want to use a HIPRI connection: (ex: WIFI turned on, use HIPRI 3G): http://groups.google.com/group/android-developers/browse_thread/thread/d41f85505484d29b
我不相信你可以逼没有明确关闭Wi-Fi无线电暂时连接路径(不推荐)。但是,你可以尝试在你希望这种情况发生期间设置网络preference:
I don't believe you can "force" the connection path without explicitly turning off the Wi-Fi radio temporarily (not recommended). However, you could try setting the network preference during the period you want this to occur:
ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
//Prefer mobile over wifi
cm.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);
//Do your work
//Remove your preference
cm.setNetworkPreference(ConnectivityManager.DEFAULT_NETWORK_PREFERENCE);
希望帮助!