Hello.
Is it possible to use Wi-Fi on the Android emulator?
Used android studio. Wrote the following function. She always says that wi-fi is disabled.

public void onTurn(View view) { TextView tv = (TextView) findViewById(R.id.textbox); tv.setText("Проверка"); WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiManager Wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); Wifi.setWifiEnabled(true); if(wifiMgr.isWifiEnabled()) { tv.append("Wifi is enabled"); } else { tv.append("Wifi is disabled"); } } 

In the manifest, he resolved everything.

 <uses-permission android:name="ACCESS_WIFI_STATE" /> <uses-permission android:name="CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> <uses-permission android:name="android.permission.WAKE_LOCK" /> 
  • and what prevents to test on the device?) - I. Smirnov
  • in 2016, no matter how ashamed I am, I do not have a smartphone (. - votanko

1 answer 1

 WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE); //Создали одну переменную WifiManager Wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); //Создали вторую Wifi.setWifiEnabled(true); //Включили одну if(wifiMgr.isWifiEnabled())//Проверяем уже почему-то другую { tv.append("Wifi is enabled"); } else { tv.append("Wifi is disabled"); } 

By the way, I have an emulsion constantly enabled wi-fi shows =)

  • Damn completely blind in old age has become. Well, yes, now constantly on shows. However, it’s still interesting how the Wi-Fi emulator works? Is he a wi-fi computer on which he finds? Can a virtual machine connect to other devices? - votanko
  • To be honest, I don’t know myself yet) - Android Android