Is it somehow possible to control the Wi-Fi connection of my Android phone from my laptop to disable (not only disconnect) the Wi-Fi connection of my phone if both my phone and my laptop are connected to the same network?

USB-Debugging is enabled on this device.

  • Do you want to disable or disconnect from the Wi-Fi? Is USB debugging enabled or SSH server running on device?
    – Firelord
    Apr 29, 2016 at 10:02
  • Dear @Firelord, USB-Debugging is enabled but no SSH server running. I want to completely disable Wi-Fi and not only disconnect to conserve energy.
    – orschiro
    Apr 30, 2016 at 5:52
  • If you have root access then through USB or Wi-Fi but using debugging mode, this command can work: adb shell su -c 'svc wifi disable'.
    – Firelord
    Apr 30, 2016 at 5:57
  • It returns error: device '(null)' not found. How can my laptop know my device over Wi-Fi, assuming that there could be other phones on the same network, too?
    – orschiro
    Apr 30, 2016 at 15:23

1 Answer 1


The following is non-root method:

  1. Create a dummy app in Android Studio. [Credit]

MainActivity.java, put right after setContentView(R.layout.activity_main):

WifiManager wfm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
try {
} catch (Exception e) {

AndroidManifest.xml, put before <application:

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  1. Enabled USB debugging settings, plug USB cable to your phone, press Shift+F10 to run the app which will also install the app.
  2. In your phone, navigate to Advanced Wi-Fi and get the IPv4 address.
  3. While USB cable still plugged, issue adb shell command,
  4. Issue pm list packages command to find out the package name if not sure. For example package:com.blogspot.diannaoxiaobai.dummyonly, remove the prefix package: is your package name. Or you can simply get the package name in AndroidManifest.xml, e.g. package="com.blogspot.diannaoxiaobai.dummyonly".
  5. Issue setprop persist.adb.tcp.port 5555 (credit) command.
  6. Ctrl+D to quit adb session.
  7. Unplug your cable. Reboot your phone now.
  8. Assume your phone automatically connected to wifi on reboot, and your laptop connected to the same wifi network. No need any USB cable now.
  9. Issue adb connect, in which this ip get from step #2 above.
  10. Issue adb shell am start -n com.blogspot.diannaoxiaobai.dummyonly/.MainActivity -e wifi false to disable wifi. com.blogspot.diannaoxiaobai.dummyonly is the package name get from step #4 above.
  11. You can remove the port 5555 set from step #5 above with adb shell setprop persist.adb.tcp.port "" command. (Credit)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .