android 获取wifi mac 地址的代码
public String macAddress = "";//wifi物理地址 public void getWifiMacAddress(){ final WifiManager wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE); if(wifi == null){ return; } WifiInfo info = wifi.getConnectionInfo(); this.macAddress = info.getMacAddress(); if(this.macAddress == null && !wifi.isWifiEnabled()){ new Thread(){ @Override public void run(){ wifi.setWifiEnabled(true); for(int i = 0 ; i < 10 ; i ++){ WifiInfo info = wifi.getConnectionInfo(); macAddress = info.getMacAddress(); if(macAddress != null){ break; } try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } wifi.setWifiEnabled(false); } }.start(); } }
相关推荐
Micusd 2020-11-19
cheidou 2020-11-19
星马殇 2020-11-18
Echodat 2020-10-08
flyToSkyL 2020-09-11
zjc 2020-09-03
阳光普照 2020-09-01
十年砍柴 2020-08-30
猪猪侠喜欢躲猫猫 2020-08-17
ladewang 2020-08-17
渣渣灰 2020-08-13
blankt 2020-08-15
vickay 2020-08-09
TinyDolphin 2020-08-09
山兔与孟婆 2020-08-09
longjing 2020-08-07
xiaogoua 2020-08-06