title: Force WiFi to send data when WiFi and Mobile are available
body: <p>In my app I have data which I want to send only if wi-fi is avaliable.
  I can check if wi-fi or mobile data is avaliable, but how do I hadle situation <strong>when both wi-fi and mobile data is active</strong>?  How do I force using wi-fi in this case?</p>
  
  <pre><code>private static void logNetworkState() {
      ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  
      NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
      NetworkInfo mobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
  
      String logStr = "Network state: ";
  
      if (wifi.isAvailable()) {
          logStr+= " wi-fi avalibale;";
      }
      if (mobile.isAvailable()) {
          logStr+= " mobile network avaliable";
      }
      log(logStr);
  }
  </code></pre>