I understand we could turn off Wifi through the "adb shell svc wifi disable" command but I don't want to completely turn off Wifi. I want to disconnect from a particular ssid through adb. Is it possible?
Edit: I got a notification saying this question is identified as a dupe of this question: How to turn off Wifi via ADB?. It actually is not. As mentioned clearly in the first paragraph, I don't want to turn off wifi but want to simply disconnect from a particular network. This is like long pressing a network and tapping "Forget network". Essentially I want to simulate a condition of the user moving out of a wifi network without having to turn off wifi.
Another useful ADB command that could be executed over WiFi without using a USB cable. It is used to install an APK to your Android device directly from the PC. Just make sure to move the APk file inside the platform-tools folder before executing the below code. If the name of the file is game.apk, then the command will be:
Disable ADB over Wi-Fi on broken Android devices. Step 1: Open the application again and click on the green button to disable ADB via WiFi. With all this, he has learned how to enable and disable ADB over Wi-Fi on rooted and unrooted Android devices.
Enabling ADB over Wifi on Android no root Step 1: Enable USB debugging (Android Settings> Developer options> Check Enable USB debugging). Step 2: Connect your device to the PC via USB. Step 3: Open the command prompt> navigate to the folder that contains ADB and type: Step 4: Now find the IP address of your Android in Settings> Wifi> Advanced.
If your Android device won't connect to Windows over ADB (ie. you are getting errors in the command line), you can try installing Minimal ADB and Fastboot from xda-developers. This package installs the necessary Android drivers and might help you get rid of any command line error.
If you have root access, you can make it by using wpa_cli.
First, you can use the wpa_cli`s list_networks to get the network id of the network that you want to disconnect
$ adb shell
# wpa_cli
> list_networks
**network id** / ssid / bssid / flags
0 001aLinksys14081-2G any [CURRENT]
and then you just need to run the wpa_cli remove_network {network id}
, where the {network id} parameter is the one that you got on the list_networks method.
One option is to use cmd wifi
. For disconnecting from a Wi-Fi network, you can "forget" it like so:
adb shell cmd wifi list-networks
adb shell cmd wifi forget-network <networkId from list-networks>
You can view the help documentation for cmd wifi
with:
adb shell cmd wifi -h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With