1.AndroidManifest.xml setting(AndroidManifest.xml 다음의 권한을 추가)
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
2. make mathod(메소드를 만들어 사용한다)
public String getMacAddress(Context context) {
WifiManager wimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
String macAddress = wimanager.getConnectionInfo().getMacAddress();
if (macAddress == null) {
macAddress = "와이파이가 안되거나 맥어드레스가 없는경우";//device has no macaddress or wifi is disabled
}
return macAddress;
}
3. call mathod from other activity(다른 엑티비티에서 사용하기)
String macaddredd = getMacAddress(this);//or this.activity()
댓글 없음:
댓글 쓰기