Oreo WiFi Connectivity

0 votes

I am working on an IoT app in which there is an on boarding process where the user connects to an access point, which has not internet connectivity, configure the device and then connects to his home Wifi network.

Android 8 devices have been causing some problems, disconnecting from the access point and reconnecting to a previously configured network. I am assuming this is related to the connectivity update which was introduced in Android 8, from section Seamless Connectivity in this link:

On compatible devices, automatic activation of Wi-Fi when a high quality saved network is nearby.

My question is how to disable this behaviour as I need to stay connected to the access point, without internet connectivity, and finish the on Boarding process.

Oct 16, 2018 in IoT (Internet of Things) by Matt
• 2,270 points
1,282 views

1 answer to this question.

0 votes

I am currently facing the same issue right now for the newer phone with Android 8.+. I am using WifiManager call bindProcessToNetwork here this will allows data traffic go through the wifi with no internet access,

here how I connect my phone to the access point

//Method to connect to WIFI Network
public boolean connectTo(String networkSSID, String key) {
    WifiConfiguration config = new WifiConfiguration();
    WifiInfo info = wifi.getConnectionInfo(); //get WifiInfo
    int id = info.getNetworkId(); //get id of currently connected network

    config.SSID = "\"" + networkSSID + "\"";
    if (key.isEmpty()) {
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
    }
    int netID = wifi.addNetwork(config);

    int tempConfigId = getExistingNetworkId(config.SSID);

    if (tempConfigId != -1) {
        netID = tempConfigId;
    }

    boolean disconnect = wifi.disconnect();
    wifi.disableNetwork(id); //disable current network
    boolean enabled = wifi.enableNetwork(netID, true);
    boolean connected = wifi.reconnect();

if (((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M))
                    || ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                            && !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M))) {

                final ConnectivityManager manager = (ConnectivityManager) context
                        .getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkRequest.Builder builder;
                builder = new NetworkRequest.Builder();
                //set the transport type do WIFI
                builder.addTransportType(NetworkCapabilities.TRANSPORT_WIFI);

                manager.requestNetwork(builder.build(), new ConnectivityManager.NetworkCallback() {
                    @Override
                    public void onAvailable(Network network) {
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                            manager.bindProcessToNetwork(network);
                        } else {
                            ConnectivityManager.setProcessDefaultNetwork(network);
                        }
                        try {
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        manager.unregisterNetworkCallback(this);
                    }
                });
            }

after connecting to the access point created by the device, it will constantly drop off from it.

answered Oct 16, 2018 by anonymous2
• 4,240 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Connect Android Things based Raspberry Pi 3 to wifi network for the first time!

Hey, I think its alright!  Your Raspberry Pi ...READ MORE

answered Jul 19, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,153 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

MQTT connectivity issues with API

Am I missing something? Most definitely. The example ...READ MORE

answered Sep 24, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
759 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Restrict Android Internet usage to WiFi without Internet Access

You can check if wifi is connected ...READ MORE

answered Jul 17, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
1,745 views
0 votes
1 answer

How to send a data from arduino uno to a webpage through esp8266 wifi module?

You are missing a few \r\n and the length ...READ MORE

answered Aug 9, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
3,658 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP