Code example for WifiManager

Methods: isWifiEnabledsetWifiEnabledstartScan

0
	 
 
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
    	//--check if wifi is off then set it to on state 
	    mainWifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
	    if(!mainWifi.isWifiEnabled()){
	    	mainWifi.setWifiEnabled(true);
	    } 
        mainWifi.startScan();
        return super.onMenuItemSelected(featureId, item);
    } 
 
    protected void onResume() { 
        registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
        super.onResume(); 
    } 
     
    class WifiReceiver extends BroadcastReceiver {
        public void onReceive(Context c, Intent intent) {
        	StringBuilder sb = new StringBuilder();
        	/*