Code example for WifiManager

Methods: setWifiEnabled

0
        mIntentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
        mIntentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
        getContext().registerReceiver(mWifiStateListener, mIntentFilter);
 
        mWifiManager = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
        mWifiManager.setWifiEnabled(true);
        assertNotNull(mWifiManager);
    } 
 
    private void sleepAfterWifiEnable() { 
        try { 
            Thread.sleep(DELAY);
        } catch (Exception e) {
            fail("Sleep timeout " + e);
        } 
    } 
 
    // Test case 1: add/remove a open network 
    @LargeTest 
    public void testAddRemoveNetwork() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE