Your code is working properly,just remove asyncTask Line and put Toast message. Then your code will run on device.its working properly. I have checked your code.i think you have to get error in async task.
try {
WifiManager wifi = (WifiManager) this
.getSystemService(this.WIFI_SERVICE);
wifi.setWifiEnabled(true);
WifiInfo info = wifi.getConnectionInfo();
String address = info.getMacAddress();
if (address == null) {
Toast.makeText(this, "Null", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, address, Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
}