title: Android Marshmallow: How to avoid Wi-Fi drop if No Internet access
body: <p>I have a Nexus 5x running MarshMallow 6.0 that is associated to the Wi-Fi of a device that has no Internet access. Android keeps dropping the connection and won't even automatically reconnect after a few tries because it detects that there is no Internet access.</p>
  
  <p>How can I force Android to keep the connection with this Wi-Fi even if there is no Internet access?</p>
  
  <p>The device is not rooted, but I can change "things" programmatically in the application that actually picks up this Wi-Fi spot.</p>
  
  <p><strong><em>Edit #1</em></strong></p>
  
  <p>In my application, I'm currently using the enableNetwork API. The documentation states:</p>
  
  <p>If an application's target SDK version is LOLLIPOP or newer, network communication may not use Wi-Fi even if Wi-Fi is connected; traffic may instead be sent through another network, such as cellular data, Bluetooth tethering, or Ethernet. For example, traffic will never use a Wi-Fi network that does not provide Internet access (e.g. a wireless printer), if another network that does offer Internet access (e.g. cellular data) is available. Applications that need to ensure that their network traffic uses Wi-Fi should use APIs such as bindSocket(java.net.Socket), openConnection(java.net.URL), or bindProcessToNetwork(Network) to do so.</p>
  
  <p>In this particular case, the potential other network (cellular data) is off as the device is forced in plane mode.</p>