I have a Xamarin Android app. It connects to a “No Internet based Wifi router” for some IOT devices. But it also needs to use mobile’s cellular data for storing some information on Dropbox.
Now this is working as follows:
- I can turn on/off Wifi connection programmatically.
- I cannot turn on/off Cellular data (since Android L). Its not allowed on non rooted devices.
- When my phone is connected to this local Wifi router and Cellular Data is also ON, the way Android works in default, it uses the Internet from Cellular connection and all my calls to Dropbox works without any issue.
- But this preference to Cellular when local Wifi has “no internet” is causing my app to never connect to local devices. Say one of my device is listening on IP 192.168.2.3 on port 9000, when I try to connect to it, my code searches it via Cellular data and returns host not found.
- So is there a way to connect to local devices in this scenario?
- As a workaround, I have manually provided modal popups to instruct users to disable Cellular when “non” Dropbox calls like connection to IOT devices are required. But this is not a good user experience as users have to keep on changing networks manually. I would like the code to handle this in a more transparent manner.
Please advise.