我使用的仿真器(安卓2.3.3)
ADB壳我开始-a android.intent.action.INSERT -t vnd.android.cursor.dir /联系-e名机器人汽车-e电话51115111
这个命令只是帮我推出新联系人,并填写姓名及电话。我需要在屏幕上砸来完成的插入。
有没有办法来完成该过程无需人工干预?
解决方案@Shimon Elbaz的是对的。
返回键可以帮助保存更改。 对我来说,(在Android 4.4.2)下一个脚本如下:
亚行外壳上午开始-a android.intent.action.INSERT -t vnd.android.cursor.dir /联系-e名称'的Android Auto22232342-e电话51115111
亚行的shell输入的KeyEvent 4
亚行的shell输入的KeyEvent 4
亚行的shell输入的KeyEvent 4
我们需要preSS HW后退按钮3次: - 第一隐藏键盘 - 第二关ContactEditorActivity(保存联系人信息) - 第三闭合联络信息活动
我的任务是增加50个联系人到设备,对,我已经写了一个简单的bash脚本:
contactCount = 50
如果(($#!= 0))
然后
让contactCount = $ 1
科幻
为((C = 0;℃下contactCount; C ++))
做
亚行外壳上午开始-a android.intent.action.INSERT -t vnd.android.cursor.dir /联系-e名'测试'$ C -e电话511151 $ C
亚行的shell输入的KeyEvent 4
亚行的shell输入的KeyEvent 4
亚行的shell输入的KeyEvent 4
等待$ PID
做完
亚行的shell输入的KeyEvent 4
要添加50个联系人运行脚本,不带参数:
./ script.sh
要添加其他计数的联系人添加一个参数:
./ script.sh
例。添加3联系人:
./ script.sh 3
另外,我觉得有一些更简单的方法来做到这一点的动作,我会很高兴地看到它=)
感谢您的关注。
I am using emulator (android 2.3.3)
adb shell "am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'Android Auto' -e phone 51115111"
this command just help me launch "new contact" and fill in name and telephone. I need to hit done on the screen to complete the insertion.
Is there a way to finish the procedure without manual intervention?
解决方案@Shimon Elbaz is right.
'Back key' helps to save changes. For me (on Android 4.4.2) next script works:
adb shell am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'Android Auto22232342' -e phone 51115111
adb shell input keyevent 4
adb shell input keyevent 4
adb shell input keyevent 4
We need to press HW Back button 3 times: - 1st hides the keypad - 2nd closes ContactEditorActivity (saves the contact) - 3rd closes contact info activity
My task was to add 50 contacts onto device, for that I've wrote a simply bash script:
contactCount=50
if (( $# != 0 ))
then
let contactCount=$1
fi
for (( c=0; c<contactCount; c++))
do
adb shell am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'Test'$c -e phone 511151$c
adb shell input keyevent 4
adb shell input keyevent 4
adb shell input keyevent 4
wait $pid
done
adb shell input keyevent 4
To add 50 contacts run script without parameters:
./script.sh
To add other count of contacts add a parameter:
./script.sh
Ex. to add 3 contacts:
./script.sh 3
Also, I think there is some easier way to do this actions, I'll be happy to see it =)
Thanks for attention.
上一篇:ActivityNotFoundException:无活动处理意向{行为= android.intent.action.VIEW DAT =文件:///mnt/sdcard/testdata5.pdf