Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force Android to use wifi network instead of mobile network

I have a use case where I need to use Wifi network for my requests instead of the mobile network. The mobile device has already connected to the Wifi network. But Android seems to always resolve network requests using the mobile data network instead of the Wifi network. Note that the Wifi network does not have internet access, it is simply a wifi access point exposed by an external device during setup.

I tried using ConnectivityManager's setNetworkPreference(ConnectivityManager.TYPE_WIFI) but that did not work.

like image 263
rajarshi Avatar asked Jun 21 '16 22:06

rajarshi


1 Answers

Disable mobile data while wifi setup is required. It won't resolve any requests with a carrier network if this is enabled.

Enable aeroplane mode, then toggle wifi

like image 63
tutacat Avatar answered Jan 03 '23 14:01

tutacat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!