Code example for WifiConfiguration

0
        // disable wifi  
        WifiManager wifiManager = (WifiManager) mActivity.getSystemService(Context.WIFI_SERVICE);
        wifiManager.setWifiEnabled(false);
         
        try {   
            WifiConfiguration apConfig = new WifiConfiguration();
             
            apConfig.SSID = SSID;  
            // no password now  
            //apConfig.preSharedKey = PASSWORD;   
            // reflect   
            Method method = wifiManager.getClass().getMethod(  
                    "setWifiApEnabled", WifiConfiguration.class, Boolean.TYPE);
             
            method.invoke(wifiManager, apConfig, true);  
        } catch (Exception e) {  
            e.printStackTrace();  
        }   
        if (LOGD_ENABLED) Log.d(LOG_TAG,"Create hotspot thread end" );
    }