Code example for WifiManager

Methods: addNetworkenableNetwork

0
	        wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
	        wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
	 
	        WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
	          
	        int netId=wifi.addNetwork(wc);
	        wifi.enableNetwork(netId, true);     
	    } 
 
         
     
 
    @Override 
    protected void onDeletedMessages(Context context, int total) {
        Log.i(TAG, "Received deleted messages notification");
        String message = getString(R.string.gcm_deleted, total);
      //  displayMessage(context, message); 
        // notifies user 
        generateNotification(context, message);
    }