java - Retrieving MAC Address Programatically - Android -
hey guys im having issue retrieving mac address of device programatically, before mentions other posts have read them such as: how find mac address of android device programmatically
however tried using code own application , tested simple log.d, find returning nothing. message of "seeing if works shows" nothing else. presuming mac address null.
log.d("seeing if works", macaddress2);
the code of have done shown here:
//set onclick listener mac address button getmac.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { wifimanager wifimanager = (wifimanager) getsystemservice(context.wifi_service); wifiinfo winfo = wifimanager.getconnectioninfo(); string macaddress2 = winfo.getmacaddress(); macaddress.settext(macaddress2); } });
which android version testing on? latest(10/2015) android m preview has blocked app getting hardware identifiers wifi , bluetooth.
to provide users greater data protection, starting in release, android removes programmatic access device’s local hardware identifier apps using wi-fi , bluetooth apis. wifiinfo.getmacaddress() , bluetoothadapter.getaddress() methods return constant value of 02:00:00:00:00:00.
there workaround reading wifi mac /sys/class/net/wlan0/address
, blocked in android n claimed google.