1

I want to give the users the ability to add contacts directly from my website. I know we cant access contact book from the browser , but I couldn't find any resources as to how to redirect users to a prefilled add contact page.

I came across chrome intents https://developer.chrome.com/multidevice/android/intents but not sure how to use them for contacts.

D V Ramana
  • 1,136
  • 11
  • 13

1 Answers1

0

I believe the official documentation you've linked to is missing another item in the intent parts type.

The intent you want to call in Java would be:

Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);

If we translate the constants to literals, that would be:

Intent intent = new Intent("android.intent.action.INSERT");
intent.setType("vnd.android.cursor.dir/contact");

If we now translate that to chrome's Android intent scheme, that would be:

var url = "intent:#Intent;action=android.intent.action.INSERT;type=vnd.android.cursor.dir/contact;end"

Note that you must have a user interaction in order for Chrome on Android to call this intent, so it needs to be in a button or similar to make it work (typing directly to the address bar will not work as well)

marmor
  • 27,641
  • 11
  • 107
  • 150