Android: Force data to be sent over radio vs WiFi

androidpacketradiowifi

Is it possible to force an Android application to use only the mobile radio connection (3g/4g/etc), disallowing the use of WiFi?

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

Best Answer

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);

Hope that Helps!