How to turn off Wifi via ADB?

Using “svc” through ADB (rooted required): Enable: adb shell su -c ‘svc wifi enable’ Disable: adb shell su -c ‘svc wifi disable’ Using Key Events through ADB: adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings adb shell input keyevent 20 & adb shell input keyevent 23 The first line launch “wifi.WifiSettings” activity which open the … Read more

android: Determine security type of wifi networks in range (without connecting to them)

I think you can find it in the source code of Settings.apk. First you should call wifiManager.getConfiguredNetworks() or wifiManager.getScanResults(), then use the two methods below: (find them in AccessPoint class “com.android.settings.wifi”): static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } return (config.wepKeys[0] != null) ? … Read more

How to get available wifi networks and display them in a list in android

You need to create a BroadcastReceiver to listen for Wifi scan results: private final BroadcastReceiver mWifiScanReceiver = new BroadcastReceiver() { @Override public void onReceive(Context c, Intent intent) { if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) { List<ScanResult> mScanResults = mWifiManager.getScanResults(); // add your logic here } } } In onCreate() you would assign mWifiManager and initiate a scan: mWifiManager = … Read more

Android Studio – Android Emulator Wifi Connected with No Internet

Stated below are the solutions for Windows and Mac, but similar solutions will work on any OS: On Windows Open Network and Sharing Center and click on current Connection Click on Properties Double Click on Internet Protocol Version 4 (TCP/IPv4) Set the Preferred and Alternate DNS servers as (Screenshot below) : 8.8.8.8 8.8.4.4 On Mac … Read more

How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo)

I thought the LocalOnlyHotspot route was the way to, but as @edsappfactory.com said in the comments – it only gives closed network, no internet access. In Oreo hot-spotting/tethering moved to ConnectionManager, and its annotated @SystemApi, so (nominally) inaccessible. As part of something else I was doing, I made an app and put it on github … Read more