I use the following code to connect to a WiFi network without an Internet connection, because it has its own web server on which I want to connect, even if the Internet connection is not available.
WifiConfiguration wifiConfiguration = new WifiConfiguration(); wifiConfiguration.SSID = String.format("\"%s\"", scanResult.SSID); wifiConfiguration.preSharedKey = String.format("\"%s\"", "secret"); int netId = wifiManager.addNetwork(wifiConfiguration) wifiManager.disconnect(); wifiManager.enableNetwork(netId, true); wifiManager.reconnect();
This works great on every Android Marshmallow device (am I using CM13, is CyanogenMod probably related?): When I use this code to connect, Android still uses a mobile connection and marks the WiFi symbol with an exclamation mark. After a few seconds, he shows a notification asking if I want to stay in touch, because the network does not have an Internet connection.
Problem. My application is trying to automatically connect to my web server, which is not working, because obviously there is no internet connection. Of course, one could wait until I can get to my web server, but it should work without user interaction.
How does ChromeCast or any other IoT device solve this? I never saw such a notification when I set up my ChromeCast device.
Forj9 source share