android adb插入联系人并需要点击"完成"才能完成

Qqb*_*log 2 android adb android-activity

我正在使用模拟器(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"
Run Code Online (Sandbox Code Playgroud)

这个命令只是帮我启动"新联系人"并填写姓名和电话.我需要在屏幕上点击完成插入.

有没有办法在没有人工干预的情况下完成手术?

m.z*_*nov 7

@Shimon Elbaz是对的.

'后退键'有助于保存更改.
对我来说(在Android 4.4.2上)下一个脚本有效:

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
Run Code Online (Sandbox Code Playgroud)

我们需要按3次HW Back按钮:
- 第1 次隐藏键盘
- 第2次关闭ContactEditorActivity(保存联系人) - 第3次关闭联系信息活动

我的任务是在设备上添加50个联系人,因为我写了一个简单的bash脚本:

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
Run Code Online (Sandbox Code Playgroud)
  1. 添加50个联系人运行不带参数的脚本:

    ./script.sh

  2. 要添加其他联系人数,请添加参数:

    ./script.sh

    防爆.添加3个联系人:

    ./script.sh 3

此外,我认为有一些更简单的方法来做这个动作,我会很高兴看到它=)

谢谢你的关注.