androidnetwork-programmingrouteswificellular-network

Force the use of the cellular connection on android while connected to WiFi


I own a diagnostic device that also acts as a Wifi access point. Any device can connect to that access point and request information from the device. The device obviously does not provide internet access over that network.

I tried to create an android app that requests information from the device, using the provided Wifi network, and then uploads the data to some server in the internet using the cellular connection.

Android, however, seems to deactivate the cellular connection whenever a Wifi network is connected. Since the Wifi network is not connected to the internet, the data cannot be uploaded, and the app is useless.

So far I tried to use the ConnectivityManager to request the mobile network and bind it to my communication socket. Also, I tried to iterate all network interfaces and bind the communication socket to the IP address of the cellular interface. However, both requests failed since I was not able to query the cellular network interface from the app.

How could I manage to forward the data from the device in the Wifi network to some server over the cellular internet connection?


Solution

  • I filed a bug report for this issue.

    The issue should be fixed in Android version 5.1.0