title: How to use data connection instead of WIFI when both are enabled?
body: <p>Both wifi and data connection are enabled.
  Since I need to use mobile data to send a http request to mobile carrier to get phone number, But android will use wifi as prior, so How can I use data connection instead of WIFI?</p>
  
  <p>When I enable the wifi and mobile data int the device. I use <code>getAllNetworks()</code> method, but it always returns wifi. I don't know Why getAllNetworks just return wifi when I enable both wifi and mobile data? </p>
  
  <p>When I just enable the mobile data, the <code>getAllNetworks()</code> return mobile data info.</p>
  
  <pre><code>ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
  Network[] network = connectivityManager.getAllNetworks();
  if(network != null &amp;&amp; network.length &gt;0 ){
       for(int i = 0 ; i &lt; network.length ; i++){
            NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network[i]);
            int networkType = networkInfo.getType();
            if(ConnectivityManager.TYPE_MOBILE == networkType ){
                 connectivityManager.bindProcessToNetwork(network[i]);
            }
       }
  }
  </code></pre>
  
  <p>Does some one know how to use data connection instead of WIFI when both wifi and data connection are enabled?</p>