title: Send data through wifi (no internet) when mobile data on
body: <p>I'm developing and application that connects to a hardware device through wifi (generated by the device) and send data to it through a socket connection.
  The problem is that when mobile data (3G/4G) is activated android tries to send the data through it instead of sending it through the wifi generated by the device, because because the wifi has no internet connection.
  I was thinking of using <a href="http://developer.android.com/intl/pt-br/reference/android/net/ConnectivityManager.html#setNetworkPreference(int)" rel="noreferrer">ConnectivityManager#setNetworkPreference()</a> but it has been deprecated in api 21.</p>
  
  <p>How can I set it to send data using the wifi generated by the device instead of the mobile data interface?</p>