Code example for WifiManager

Methods: getConnectionInfogetDhcpInfo

0
	private IP4Address			mBase				 = null;
	 
	public Network( Context context ) throws NoRouteToHostException, SocketException, UnknownHostException {
		mWifiManager		 = ( WifiManager )context.getSystemService( Context.WIFI_SERVICE );
		mConnectivityManager = ( ConnectivityManager )context.getSystemService( Context.CONNECTIVITY_SERVICE );
		mInfo		 		 = mWifiManager.getDhcpInfo();
		mWifiInfo			 = mWifiManager.getConnectionInfo();
		mGateway 			 = new IP4Address( mInfo.gateway );
		mNetmask 			 = new IP4Address( mInfo.netmask );
		mLocal	 			 = new IP4Address( mInfo.ipAddress );
		mBase				 = new IP4Address( mInfo.netmask & mInfo.gateway );
		 
		if( isConnected() == false ) 
			throw new NoRouteToHostException("Not connected to any WiFi access point.");
		 
		else 
		{ 
			try 
			{ 
				mInterface = NetworkInterface.getByInetAddress( getLocalAddress() );			
				if( mInterface == null )