Code example for WifiManager

Methods: getConnectionInfogetDhcpInfo

0
 
	public GetIPInfo(Context ctx) {
		mContext = ctx;
		res = mContext.getResources();
		wifi = (WifiManager)mContext.getSystemService(Activity.WIFI_SERVICE);
		mIpAddr = MainActivity.intToIp(MainActivity.littleToBigEndian(wifi.getDhcpInfo().ipAddress));
		mMacAddr = wifi.getConnectionInfo().getMacAddress();
	} 
 
	public String getHardAddr(String ip) {
		if(ip == null)
			return null; 
		if(ip.equals(mIpAddr))
			return mMacAddr;
		BufferedReader br = null;
		String ret = null;
		try { 
			br = new BufferedReader(new FileReader("/proc/net/arp"));
			String line;
			while ((line = br.readLine()) != null) {
				String[] splitted = line.split(" +");