I don’t know how many people ever get into a situation where they have to make a call or send a text message using commands. ADB allows Android users to perform various tasks, such as managing apps, capturing screenshots, recording screen activity, and transferring files between devices and computers. This tutorial purports to introduce our readers to the extensive capabilities of ADB in controlling Android devices from a command-line interface.
You can send and execute ADB commands in 3 ways.
ADB Command to Make a Call
The quickest way to make phone calls is via the Phone app. However, if your phone’s touchscreen is non-functional, you can use ADB commands to dial a number. Follow the steps below to make a call from your Android device without touching it.
- Launch a PowerShell window with the path of the ‘platform-tools’ folder.
- To invoke ADB Shell, type
adb shell
in the command window and press Enter. - Now type or paste the following command in PowerShell.
am start -a android.intent.action.CALL -d tel:+19792211000
- Replace the phone number in the command with the number you want to call.
- When you hit Enter, your Android device will dial the number.
Picking up and Ending a Call with a Command
You can make calls, pick up an incoming call, or cancel it. Here’s how to do that. Launch a PowerShell window and execute the following command to accept an incoming call on Android:
adb shell input keyevent KEYCODE_CALL
To cut or hang up an incoming call, execute the command given below:
adb shell input keyevent KEYCODE_ENDCALL
ADB Command to Send Text Message
You can also send text messages to any phone number from your Android device via the command-line interface on your Windows, Mac, or Linux computer.
- Open a PowerShell window and execute the
adb shell
command. - Right after the dollar sign ($), type the following command. Do not forget to replace the phone number and message body (highlighted in blue).
am start -a android.intent.action.SENDTO -d sms:+17007800006 --es sms_body "Test Message from Technastic.com"
- This command will open the Messages app and input the message content in the text field.
- To send your message, you’ll need to execute the following key event commands one after another to send your message to the recipient.
input keyevent 22
input keyevent 66
Note: The key event codes to emulate the send button may not work on Android devices with Gboard or any 3rd-party keyboard app. Please use the default keyboard of your device. You may need to find the correct key event values to trigger the send button.
ADB Command to Input Text on Android
There is an ADB command to input text in apps like Instagram, WhatsApp, Facebook, Twitter, etc., or search for something on Google with a text query.
Open a PowerShell or Command Prompt window on your Windows PC. Then type or paste the following command.
adb shell input text 'I love this adb command'
Feel free to replace the highlighted text body in the above command with yours and press Enter.
Now that ADB has printed the text on your Android device, execute the following key event code shown in the screenshot.
adb shell input keyevent 22
The text will be printed in the currently open app’s text field. If no app is open on your phone, this command will send the text to the Google Search box.
If you want to save yourself from navigating to the ‘platform-tools’ folder to launch a command window with a path, consider setting up system-wide ADB on Windows.