adb connect wireless code example
Example 1: adb wifi connect
# Connect device via USB and enable USB-debugging in developer options
adb devices
# to get device id
adb -s <device id> tcpip 5555
# Find out the local IP address of the Android device.
# You can find this information by pressing/long-pressing the WiFi icon in the quick
# settings drop-down and then clicking the WiFi network you are connected to.
adb connect <IP address>:5555
# done!
Example 2: wireless adb
#ANDROID 10 OR LOWER
# 1. Connect your Android device and adb host computer to a common Wi-Fi network.
# 2. Connect the device to the host computer with a USB cable.
# 3. Set the target device to listen for a TCP/IP connection on port 5555.
$ adb tcpip 5555
# 4. Get the IP of the target device
# Run the following command in the devices shell and copy the IP address after
# the "inet" until the "/"
$ adb shell
$ ip addr show wlan0
# 5. Disconnect the USB cable from the target device.
# 6. Connect to the device by its IP address.
$ adb connect <device_ip>
# 7. Confirm that your host computer is connected to the target device:
$ adb devices
List of devices attached
<device_ip>:5555 device
# if there are multiple devices attached
# specify which device to communicate with using the -s option
$ adb -s <device_ip> <command>