0
我試圖讓Eclipse的Android模擬器的Wifi網絡的MAC ADDRES本:獲取MAC地址的Android APP崩潰
WifiManager wifiManager = (WifiManager) LoginActivity.this.getSystemService(WIFI_SERVICE);
WifiInfo wInfo = wifiManager.getConnectionInfo();
String macAddress = wInfo.getMacAddress();
System.out.println("HI");
System.out.println(macAddress);
這是Android清單權限
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
當執行到達
System.out.println(macAddress);
該應用程序與Java nullpointerexception崩潰,並關閉它。
什麼問題?我必須爲模擬器添加wifi連接性?
你不能用wify連接模擬器[link](http://stackoverflow.com/questions/7876302/enabling-wifi-on-android-emulator) –