1. Are you ready for the Galaxy S20? Here is everything we know so far!

Very slowly connecting to wifi

Discussion in 'Android Development' started by Ivan Ivanov, Feb 26, 2016.

  1. Ivan Ivanov

    Ivan Ivanov Lurker
    Thread Starter

    Hello I am new in Android and I am developing a simple app which needs just to connect the device to a particular WiFi network. However, sometimes I need to wait the phone to connect like 3-4 minutes. The code I use for connecting is the following:
    Code (Java):
    1. WifiConfiguration robotNetwork=new WifiConfiguration();
    2.                 myNetwork.SSID="\""+mySSID+"\"";
    3.                 myNetwork.preSharedKey="\""+myPass+"\"";
    4.                 int netID=wifi.addNetwork(myNetwork);
    5.                 wifi.enableNetwork(netID,true);
    6.                 wifi.reconnect();
    What am I doing wrong?

    Thank you in advance!!!

    1. Download the Forums for Android™ app!



Share This Page