title: How to connect to local network first instead of internet in C# Xamarin Android app?
body: <p>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. </p>
  
  <p>Now this is working as follows:</p>
  
  <ol>
  <li>I can turn on/off Wifi connection programmatically.   </li>
  <li>I cannot turn on/off Cellular data (since Android L). Its not allowed on non rooted devices.  </li>
  <li>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.  </li>
  <li>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. </li>
  <li>So is there a way to connect to local devices in this scenario?</li>
  <li>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. </li>
  </ol>
  
  <p>Please advise. </p>