Skip to content Skip to sidebar Skip to footer

Android Volley Doesn't Work On Local Wifi If 3g/4g Is On

I have an app that communicates with a Ricoh Theta camera. The camera creates its WiFi network and OSC (Open Spherical Camera) web server (IP 192.168.1.1, port 80), on which I conn

Solution 1:

OK, sorry, after some research I found the solution, here: https://code.google.com/p/android/issues/detail?id=190974

The problem is that as of Android 6.0, if the device is connected to several networks, Android will connect to the one with an internet access, and ignore the other(s). Seems pretty weird, to be polite, but still...

Here is the code I added to make it working:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {

    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    for (Network net : connectivityManager.getAllNetworks()) {
        NetworkInfo networkInfo = connectivityManager.getNetworkInfo(net);
        if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
            connectivityManager.bindProcessToNetwork(net);
            break;
        }
    }
}

Post a Comment for "Android Volley Doesn't Work On Local Wifi If 3g/4g Is On"