I need to wait until android enables wifi ( you can’t just “setWifiEnabled(true)” and expect to be enabled instantly). I need proper way to do that.
I have some code and its working, but i don’t think its proper way to get job done ( i think )
while(wifiManager.getWifiState() != 3) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I already checked wait until wifi connected on android , but i didn’t found answer i need.
The right way is to register for wifi connection events. Then Android will call you when its connected. See How to detect when WIFI Connection has been established in Android?