Android - How to add contacts using adb without user interaction?

For your Android 4.4.2 device the command to add a contact is (replace the Bo Lawson and #123.. to whatever you want):

adb shell am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'Bo Lawson' -e phone 123456789

Now to get it to save. This is Android 4.4.2 specific. Pressing back will save it. For this you need to use key events. With Android 4.4.2 it is key event 4. You are going to need to do it at least twice. Once to exit the keyboard, the other to exit and save. If required use it again to completely exit from Contacts app.

adb shell am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'Bo Lawson' -e phone 123456789
adb shell input keyevent 4
adb shell input keyevent 4

This worked on my rooted Samsung Galaxy Tab Pro running Android 4.4.2.

Edit: I found a post on Stack Overflow which references this command.

Tags:

Contacts

Adb