Paolo Montalto
1 min readAug 26, 2020

--

Let your Android app navigate on a WiFi w/o internet access when mobile data is on

Recently a client contacted me because their mobile app could not connect to a webpage served from a WebServer located inside a WiFi network without internet access.

It seemed that they could connect to the same page only by disabling mobile data on the phone and that this regularly occurred on Android 10 devices and randomly on Android 9 smartphones.

It turned out that on Android the connection sporting Internet access is always considered as the preferred one and in certain conditions packets never get routed to the other available connection before being timed out.

In order to address this issue since API level 23 a proper method is available in ConnectivityManager to bind the app process to a specific network

public boolean bindProcessToNetwork (Network network)

Thus you can just this method to assure packets are getting routed through the right connection as follows:

--

--

Paolo Montalto

Android Engineer, freelance, mobile developer, software craftsman, guitar strummer, husband, father, humble.