title: Use multiple network interfaces in an app
body: <p>I wrote an app  that is triggering a Sony qx smartphone attachable camera over wifi. However I need to transfer the images off the phone over another local network in real time. Since the wifi card is being used for qx connection I need to be able to use  ethernet over usb for transferring images off the phone. Http requests will be used to trigger the camera and send the images off the phone. </p>
  
  <p>Is it possible in one android app on a phone with two network interfaces setup to specify for certain http requests to use one network interface and for others to use another network interface ? Does this need to be done through routing tables, not java?</p>
  
  <p>The phone I'm using is a rooted nexus 6p.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Currently, I was able to get an Ethernet adapter working with the device (Nexus 6P). The device is connected to a local network over Ethernet. When the Wi-Fi interface is off, I can ping all devices on the local network the device is connected to over Ethernet. However, I am unable to access the web servers (Not using DNS) of any of the devices on that network (which I know they are running), i.e. Http via a browser app. The nexus 6p is connected to the network over Ethernet via a Ubiquiti Station. This seems to be a routing issue.</p>
  
  <p>I can tether(usb interface) and use Wi-Fi in one app, so that leads me to believe it is possible to use Ethernet and Wi-Fi. </p>
  
  <p><strong>Update2</strong>:</p>
  
  <p>After more testing, it seems to be that it is a permissions issue. Since when I ping the network the device is connected to over Ethernet without first running <code>su</code> in the terminal the network doesn't exist. However, when  I run <code>su</code> then ping, I can ping the network. Thus it seems my app needs to get superuser permission before accessing Ethernet. I've granted it superuser access, but nothing has changed. I read that simply running <code>su</code> isn't enough from one of the comments in this <a href="https://stackoverflow.com/questions/7295873/how-do-i-request-root-access-in-android">post</a>. This is because <code>su</code> just spawns a root shell that dies. This also explains why I couldn't access any of the web servers on this network via a browser app. Is it possible to grant my app access to the Ethernet interface when making HTTP calls like give <code>HttpURLConnection</code> root access, if that makes any sense (running <code>su</code> doesn't work)? There seems to definitely be a solution since  HttpURLConnection can make calls over the USB tethering interface (Nexus 6P calls it <code>rndis0</code>) fine.</p>
  
  <p><strong>Update 3</strong>:</p>
  
  <p>I found online <a href="http://www.addictivetips.com/mobile/how-to-install-any-app-as-system-app-on-android/" rel="nofollow noreferrer">here</a> , that I can make my app a System app (thought this might grant the app eth0 access). I just moved my app to <code>/system/app</code> and then rebooted. However, this didn't seem to give the app anymore privileges (thus not solving the problem) , or there is something else required to make the app system than just copying it to <code>/system/app</code>.</p>
  
  <p><strong>Update 4</strong>:</p>
  
  <p>So I was able to get Ethernet working on every app without root permissions! It seemed to be that it only works over DHCP and does not like static connections, which I was using. It works with Wi-Fi enabled, however, I cannot contact any of the devices on the Wi-Fi network when Ethernet is enabled. Is there a way around this? Does it have to do with setting two default gateways?</p>