Wifi Mac address 말고
휴대폰에도 각각의 MAC Address가 존재한다.
다음과 같이 이용할 수 있다.
public static String getMacAddress() {
try {
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all) {
if (!nif.getName().equalsIgnoreCase("wlan0")) continue;
byte[] macBytes = nif.getHardwareAddress();
if (macBytes == null) {
return "";
}
StringBuilder res1 = new StringBuilder();
for (byte b : macBytes) {
res1.append(String.format("%02X",b));
}
if (res1.length() > 0) {
res1.deleteCharAt(res1.length() - 1);
}
return res1.toString();
}
} catch (Exception ex) {
//handle exception
}
return "";
}
'프로그래밍 > Android' 카테고리의 다른 글
Android Hash 키 가져오기 (0) | 2018.11.20 |
---|---|
Android Device ID 가져오기 (0) | 2017.12.12 |
Bluetooth 설정 화면 창 바로가기 (0) | 2017.06.13 |
Android 공유하기 (ACTION_SEND) (0) | 2017.04.05 |
android NDK 64bit 호환 처리하기 (0) | 2017.04.04 |