I'm working on an application that will run on a phone where the phone will be a station on a private Wi-Fi network. The phone will be a station, not an access point, and the private Wi-Fi network does not route to the Internet. My application needs to communicate with servers on the Internet as well as devices on the local Wi-Fi network, so it needs to have connections on both networks at the same time. I've been trying to figure out how to do this.
I've been trying the technique described in the discussion on the
Google Android developers group titled "Can
Android 2.X connect to 3G and Wifi data networks simultaneously?", but
it is not working well. What I find is that, when I enable the
cellular network by calling
ConnectivityManager.setNetworkPreference(ConnectivityManager.TYPE_MOBILE)
,
any sockets I have open on the Wi-Fi network are closed. I haven't
tried it, but I suspect the same thing will happen to sockets on the
cellular network when I switch back to Wi-Fi.
Another problem is that, these calls operate on a global level, changing the network settings for the entire phone, not just the application. Switching the network set up globally like this will interfere with any other app that happens to be running on the phone. Even after my application exits, the phone continues to run with the last network configuration it set.
I'm looking for a way to have connections open on both the cellular data and Wi-Fi networks at the same time, and without interfering with other applications running on the phone.
- Does anyone know how to do this?
- Does anyone know if this is possible?