I am trying to create a widget for enabling and disabling the wifi.

if(myWifiManager.isWifiEnabled()){
            System.out.println("Toggle Wifi Enabled going to disable");
            myWifiManager.setWifiEnabled(false);
        }
        else{
            System.out.println("Wifi Disabled going to enable ");

            myWifiManager.setWifiEnabled(true);
            System.out.println("WI: "+myWifiManager.isWifiEnabled());
        }

This is the code i am using the disabling part is working fine but the enabling part is not working fine. Soon after enabling the wifi i am printing the wifi state i am getting it as false.

Edit
Report