30

I would like to make call via ADB command on android's command line.

How should I use ADB command in order to make a call via PC?

please provide source code.

Matteo
  • 7,924
  • 24
  • 84
  • 129
user604190
  • 309
  • 1
  • 4
  • 5
  • what makes you think it's possible ? ddms does it through native code i'm not so sure it's android commands he's issuing on the shell... – codeScriber Feb 07 '11 at 16:29
  • The only thing magic about ddms is that it knows how to do many things, which in this case is no great mystery. The ADB daemon however has some magic, in the form of permissions not available to other code running on (a secured) device. But that is made available to your code on the PC, not just Google's. – Chris Stratton Feb 07 '11 at 22:01
  • Related: [How to pick up a call by adb](https://stackoverflow.com/q/10442232/3258851) – Marc.2377 Jun 12 '19 at 20:50

6 Answers6

47

You should do (replace <serialno> by the serial number of your device or emulator, for example emulator-5554):

$ adb -s <serialno> shell am start -a android.intent.action.CALL -d tel:555-5555

and see this in the logcat:

Starting: Intent { act=android.intent.action.CALL dat=tel:xxx-xxx-xxxx }
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
9

You can do this one by:

  1. Enter into your adb in cmd
  2. Enter adb devices. What ever id you will get that will be you device number
  3. Enter (Without quotes):

adb -s "Your devices number" shell am start -a android.intent.action.CALL -d tel:"phone no. to call"

That's it and you will get the response as:

Starting: Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxx }
Draken
  • 3,134
  • 13
  • 34
  • 54
Sukirti Dash
  • 119
  • 1
  • 5
9

One can use this command make a call to a number via Android triggered by PC.

adb shell am start -a android.intent.action.CALL -d tel:+CCXXXXXXXXXX
  1. cc=country code
  2. XXXXXXXXXX=Phone Number
3

On some Android devices, there exists an executable

/system/bin/radiooptions

If you run it, the help dislplays

Usage: radiooptions [option] [extra_socket_args]
           0 - RADIO_RESET, 
           1 - RADIO_OFF, 
           2 - UNSOL_NETWORK_STATE_CHANGE, 
           3 - QXDM_ENABLE, 
           4 - QXDM_DISABLE, 
           5 - RADIO_ON, 
           6 apn- SETUP_PDP apn, 
           7 - DEACTIVE_PDP, 
           8 number - DIAL_CALL number, 
           9 - ANSWER_CALL, 
           10 - END_CALL 

For dialing a number, you can simply run

adb shell su -c "radiooptions 8 XXXXXXX"

where XXXXXXX is to be replaced by the phonenumber.

I saw this command on quite many HTC devices. I run currently a Cyanogenmod 10.2 on an HTC One, and there it is as well. It could also be possible, that it is only available on devices with a Qualcomm radio chip.

Adrian Schneider
  • 1,427
  • 1
  • 11
  • 17
  • radiooptions does not exist in /system/bin on my Lollipop One+ One – tommed Aug 06 '15 at 13:00
  • This is almost only for HTC and seems that has been removed from some of them. If you try in other it will probably complain about to be PIE capable. You may be able to use if you compile it with -fPIE option. – m3nda Nov 26 '17 at 04:03
1

you can launch the dialler, by first finding the package using

adb shell dumpsys window windows | grep -E 'mCurrentFocus'

then launching it using

adb shell monkey -p <package> 1 (probably com.android.contacts)

ensure you're on the dialler and not the contacts page by clicking the coordinates of the dialler

adb shell input tap <x> <y> (in my case 65, 80)

type the number

adb shell input text <number>

and then hit the dial coordinates

adb shell input tap <x> <y> (in my case 220, 750)

For sure this answer is overkill. However, all of the previous answers i've encountered will then launch a dialog asking which application you wish to use to complete the action - skype, viber, etc., meaning if you have either not chosen a default dialler but have ott calling apps installed, or else have specified an alternative default dialler, the call will not be made over gsm. This method will ensure that gsm is used.

rbennell
  • 1,134
  • 11
  • 14
  • 2
    all of that is totally not needed when you can just call android.intent.action.CALL and then provide a number. Remember to use +COUNTRY_CODE to be able to call automatically. If you supply a mobile number it works with no problem, otherwise you just see the dialer open with the number and nothing happens. Tapping in the screne is not bullet proof, i even see it sending me to Home instead of tap on the current Intent. – m3nda Nov 26 '17 at 04:02
0

adb shell input keyevent 5 && adb shell input text 1234567890&&adb shell input keyevent 5

Here 1234567890 is phone number