title: Android runtime exec with NetworkRequest
body: <p>I am running a command line argument in my Android application like:</p>
  
  <pre><code>ProcessBuilder pb = new ProcessBuilder(cmds);
  Process process = pb.start();
  process.waitFor();
  </code></pre>
  
  <p>Where <code>cmds</code> are a list of arguments to run. My commands probe a remote URL over a http connection. My device is connected to a WiFi network that does not have access to the internet, but does host the URL I want to probe. My device also has a cellular connection that does have access to the internet, but not the URL. My device is running Android 6.0 Marshmallow.</p>
  
  <p>Normally in Lollipop or above, Android defaults to the network with a connection to the internet. To access WiFi networks without internet you need to use <code>NetworkRequest</code>, e.g: <a href="https://stackoverflow.com/a/27958106/1847734">https://stackoverflow.com/a/27958106/1847734</a>.</p>
  
  <p>How can I pass an obtained <code>Network</code> to the above <code>Process</code>, so that the connection goes over my WiFi network, not my cellular network?</p>
  
  <p>Do I instead need to use <a href="http://developer.android.com/reference/android/net/ConnectivityManager.html#bindProcessToNetwork(android.net.Network)" rel="nofollow noreferrer">ConnectivityManager#bindProcessToNetwork</a>? How do I join the process to set the network using this method? There doesn't seem to be an option to give the process.</p>