1

Ok, so my question is may be off topic but i really did not found any useful content to use both network interface simulnasily in my application is simple image uplaod to server using both open network for better speed.here can we use both network by programing in java? i found this code snippet but its return only connection status.

 ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
            Network etherNetwork = null;
            for (Network network : connectivityManager.getAllNetworks()) {
                NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
                if (networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) {
                    etherNetwork = network;
                }
            }
            Network boundNetwork = connectivityManager.getBoundNetworkForProcess();
            if (boundNetwork != null) {
                NetworkInfo boundNetworkInfo = connectivityManager.getNetworkInfo(boundNetwork);
                if (boundNetworkInfo.getType() != ConnectivityManager.TYPE_ETHERNET) {
                    if (etherNetwork != null) {
                        connectivityManager.bindProcessToNetwork(etherNetwork);
                    }
                }
            }
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Subhash Pandey
  • 111
  • 1
  • 6

2 Answers2

0

As far as I know it is not possible.

Nevertheless:

  • MPTCP exists, and you may find roms that support it, but it is not out of the box.
  • Speedify claims to be able to do it, but since it doesn't require root, I assume it's just a clever use of a VPN connection and a sort of load balancing trick between connection types.

Basically, in order to really have the 2 connection types active, you would need to modify the kernel so that both network interfaces can be used at the same time.

2Dee
  • 8,609
  • 7
  • 42
  • 53
0

You can follow the approach I'm using in this app if it helps

https://github.com/yschimke/OkHttpAndroidApp/

You can bind each socket yourself to a specific network interface before you connect. Each individual socket needs to be on a single network, but you can use both.

https://github.com/yschimke/OkHttpAndroidApp/blob/master/android/app/src/main/java/com/okhttpandroidapp/factory/AndroidNetworkManager.kt#L123

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69