Reputation: 21345
For a long time my device would always auto start WIFI now it does not. Could someone show how to turn wifi on automatically when device boots? Also if my app sleeps sometimes on recovery wifi is gone? Show how to test if wifi is active and if not active how to turn it on programatically. Thanks
Upvotes: 0
Views: 271
Reputation: 500
Use wifi manager class and use the following code to test wifi connectivity
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if(wifi.isWifiEnabled()) { // write your code }else{ wifi.setWifiEnabled(true); }
Upvotes: 2