When I need to see my doctor I have to:
Call to 666666666
Wait 5 seconds
Press 1
Wait 5 seconds
Press 20301990
Wait 5 secondos
Press 1
So I want to automatizate all this steps
I know that I can fire the call doing:
adb shell am start -a android.intent.action.CALL -d tel:666666666
and I can simulate a input by:
sleep 5
adb shell input text "1"
sleep 5
adb shell input text "20*30*1990"
sleep 5
adb shell input text "1"
but It can't work if I don't open de dial pad after adb shell am start -a android.intent.action.CALL -d tel:666666666 and before adb shell input text "1"
So my question is: How can I open the dial pad during a call using adb?
You can find the coordinates of the dial's pad button and then simulate a press by sending input tap x y.
If your automation will be used on multiple devices from different types, I would advise you to write a simple python script that uses uiautomator to do that task.
Related
I have been trying to send a command to my device to double tap on the screen.
I tried to send this
adb shell input tap 600 1000
adb shell input tap 600 1000
However, it does not result into a doubletap.
Anyone willing to help me out?
This has worked for me pretty reliably until android 10; however, it no longer works on android 11 :(
I figured out a way to do it like this:
input tap <x> <y>&
sleep 0.1
input tap <x> <y>
as in
adb shell "input tap 520 1150& sleep 0.1; input tap 520 1150"
When digging around android 11 it seems that input command spawns up a JVM that is very slow, and it slowed down enough on android 11 to about 0.5 seconds, so the system does not recognize it as a double tap.
You can speed up the taps (or any user input) by including it in the same adb shell command. Previously I did this:
adb shell "input tap 520 1150; input tap 520 1150"
This will be easier on your system memory (as only one input command is executing at once) and may work pre android 11, but the one with & and explicit sleep between the two taps is what I switched to now.
How can I create new contact using adb?
I'm using the following command:
adb shell "am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'Bo Lawson' -e phone 123456789"
But now, Should I need to click on Save, So how can I do it fully automatic using adb?
Try adb shell input keyevent 3 This will take your phone back to the home screen which will automatically save the contact.
You can use adb to simulate touch events by using the following command
adb shell input tap x y
Did anyone tried Android multiple display feature which is new in Android O
Following steps which is not working for me
1.connect hdmi cable to mobile(not sure can use USB as well)
2.make device in root and give following command (expect app is installed)
and not seen that app is launching on secondary(Multiple display feature
) it's just reflecting mobile display as it is because connected hdmi cable
adb shell am start com.Chrome.Canary --display 1
Please suggest any other way or any command to make it work?
Android in general do mirroring when two displays are connected. Right now google has not enabled support for touch and display mapping on the two displays. But if you want to launch any activity on any of the two displays then the command adb shell am start "your_activity" --display display_id will launch your activity on that particular display id. If the above command doesn't launch your activity then you can use adb shell am stack start display_id "your activity". This will also work. But regarding touch, it will be mapped to the primary display (display id 0). As per google you can enable the mapping of touch in EventHub.cpp of Android source code but till now I haven't found it useful. Hope my answer helps you.
Ran using below procedure passed with dell monitor:
ADB shell can be used to call Activity Manager(am) for starting any system actions (or an activity).
The syntax:
adb shell am start [-n (component)] [-a (action)] [-t (mime type)] [-d (data_URL)]
examples:
1. For starting ‘Settings app’:
adb shell am start -n com.android.settings/.Settings
In the above-mentioned command, we set component(-n) to be settings in a specific format.
For starting ‘Gallery app’:
adb shell am start -t image/* -a android.intent.action.VIEW
In the above-mentioned command, we are setting action(-a) for opening the default app for gallery with mime type(-t) to be image/*
In general, for external display the ‘display_id’ starts from ‘1’ in an increasing order, final command to do multi display operation is
adb shell am start -n com.android.settings/.Settings --display 1
The above command will display ‘Settings’ app only in external display with display_id = 1. The primary display will be in the same mode as before executing the command.
I want to input swipe commands back to back using a c program and adb shell to my android device .
But the lag between the commands is preventing me from achieving my goal.
Is there anyway to reduce this lag??
You can record some input and repeat it directly.
For example:
Record:
cat /dev/input/event0 > inputdata
Replay:
cat inputdata > /dev/input/event0
To find the correct event number you can use the getevent -p command.
There is no "lag between the commands". The input command is a java application and it takes about a second (depending on your device) to launch it. So you can not inject 2 events back to back faster than that.
You could either write your own input command which would accept multiple sets of coordinates in one take thus eliminating the need to run the command multiple times. Or you could use series of sendevent commands for emulating your gesture instead.
I can use something like:
adb shell input keyevent 4
and this will send a single 'Back' button press to my device. How can I send a longpress?
Thanks
You can try this command:
adb shell input touchscreen swipe 170 187 170 187 2000
Your application position on screen is
170, 187; delay time is 2000 (ms);
Long press HOME key:
adb shell sendevent /dev/input/event2 1 172 1
adb shell sendevent /dev/input/event2 0 0 0
timeout 1
adb shell sendevent /dev/input/event2 1 172 0
adb shell sendevent /dev/input/event2 0 0 0
You can goto cmd and type adb shell getevent | find "event2" ; long press HOME key to see more.
Since this commit in Android 4.4 it is possibile to use:
adb shell input keyevent --longpress KEYCODE_L
This other commit further improved the behaviour.
When you want to delete something or repeat some Event or just input a lot of numbers, you can use code like the following. It will imitate a longpress on a keyboard:
adb shell input keyevent KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL //delete 3 times
adb shell input keyevent KEYCODE_1 KEYCODE_1 KEYCODE_1 //input value '111'
You can repeat the event or input things without limits, just like a Longpress on the key. It's the same thing. You can define your own longpass and times Now
This link discusses a similar problem, but the device in question (a Nexus One device)has the menu/home/back/search buttons as part of the touchscreen, not physical keys.
This other one appears to be more inline with injecting a physical key input, but requires accessing the *.kl file for your devices driver to determine the device, type, key-code, value-press, and value-release codes for that specific device.
However, the common link between the two appears to be
adb shell sleep n
, where n is the length (in seconds) of the press duration.
Hopefully this might be of some use.
Well, this developer link show the keycode is 128, which i already test, but no expected result
You can check this link and this link. They show how to find it.
This might be too late to answer but surely will help others.
Please use below cmd to achieve long press.
adb shell input keyevent 5 sleep 5