My application creates a Wi-Fi connection to a sensor but this means that the user will have no connection to the Internet as long as he is connected to this peripheral.
I've already read that it is not possible to have two wifi connection without rooting the device.
I guess I've already read all posts on stack overflow concerning this topic but all of them are quite old.
It would be ok if I could use at least the mobile network for Internet so that the user is able to use the browser or other applications while connected.
I tried to set the preferred network but this is not working.
try {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (forceMobile) {
connectivityManager.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);
} else {
connectivityManager.setNetworkPreference(ConnectivityManager.DEFAULT_NETWORK_PREFERENCE);
}
} catch (Exception exc) {
}