Fake Incoming Call Android
How can I fake an incoming call inside the android emulator?
The following lets me make a call but I'd like to force the emulator to receive a call, preferably from a number I've selected.
adb shell开发者_运维知识库 am start -a android.intent.action.CALL tel:1112223333
So, the direct opposite of the command above.
You can use DDMS in Eclipse, Android Device Monitor in Android Studio or run command lines on terminal
Using DDMS:
- Open DDMS/ADM
- in Eclipse: Window > Open Perspective > DDMS
- in Android Studio: Tools > Android > Android Device Monitor
- Enter the fake incomming phone number
- Choose "Voice"
- Press call
After that, you will see the emulator receive this phone call as follows
Using command lines
$ telnet localhost 5554
$ gsm call 123456789
Note: 5554: console port number for emulator instance
12345678: incoming phone number
Actually in android Studio 2.1 Its easy!
You can do this with Putty. Download and install Putty http://www.chiark.greenend.org.uk/~sgtatham/putty/
Step 1: Run Putty
Step 2: In the address box put 127.0.0.1
In the port box put the port number your emulator is running on. It's in the top left corner of the emulator window (usually 5554). Make sure type is set to 'telnet'. Click 'Open'
Step 3: A terminal will open. Type:
gsm call <the number you want the phone to see>
Press enter and you're done.
EDIT: You can also send fake sms:
sms send <the number you want the phone to see> <the message>
if you are using eclipse then you can simply do this using emulator control for this click on window in eclipse menu then show view now click on other a small window will open select android and then emulator control
use it for making call in emulator
Another option for testing the same behavior is to use a real phone and Google's two step authorization settings to generate calls (see image).
There are three options which i recently checked to get simulated call on a Android emulated device (AVD).
option 1:
Go to emulated device "more" option as shown below and hit on "Call device" to get a call from number mentioned.
option 2:
Using emulated device UI check the phone number by going to Settings--> System --> About emulated device as shown below. Call to this number from the other device.
option 3:
Launch Android device monitor (e.g. on windows "C:\Users\xyz\AppData\Local\Android\Sdk\tools" launch monitor), set your own incoming number and call as shown below
Shell script incoming_call.sh:
#!/bin/sh
expect << EOF
spawn telnet localhost 5554
expect -re ".*>"
send "gsm call $1\r"
expect -re ".*>"
send "exit\r"
EOF
Usage:
incoming_call.sh +55555555555
Handy one-liner on unix-like systems using telnet and netcat:
$ echo "gsm call 123456789" | nc -v localhost 5554
on a real device
adb shell am start -a android.intent.action.CALL -d tel:+CCXXXXXXXXXX
CC is country code , XX is phone number
You can do this by connecting to your emulator via telnet.
Open Command Prompt and enter
telnet localhost <console-port>
You can find your <console-port>
on the title bar of the emulator.
According to the above instance my <console-port>
is 5554.
After connecting to the emulator via telnet, enter
gsm call <telephone-number>
精彩评论