It's not easy what you would do.
First in first you must keep on both network interface, this is possible but it's an hack because Android doesn't support it. To do it you must switch on
connectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "feature");
The feature name is related to your hardware, it should be enableHIPRI. The problem is that after you switch on the interface this will turn down after some time, for this reason you must perform a http request every 20-30 seconds to keep it up. This way the interface will stay on.
To the route, you should add static route
connectivityManager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE_HIPRI, ipAddressInt);
Where the ipAddressInt
is the address that you want to connect on 3G. Normally the routes are sent throughout WiFi, so for your GET (download on WiFi) there is no problem, but you should add a route for upload.
And now there are 2 problems,
- first is that in this way on 3G the DNS resolution is gone, you can work on IP but you must have a server with static IP,
- second, I'm not sure if it works on a specific port (that is the only idea that I have in this moment to do it...).
Of course you should implement another thread that keep alive the interface.