6

I'm trying to create a link on my website where you can click and add my info to your phones contacts. Is there a file format that android will recognize & load a contact from?

ale
  • 19,723
  • 34
  • 110
  • 159
MrGlass
  • 163
  • 1
  • 5

1 Answers1

6

The easiest way is to use a barcode you could e.g. create with an app like My QR code Generator. If you do not want to install an app for the purpose, there are also web services available like e.g. GOQR.ME -- simply search google for QR Code generator vcard.

The result is a QR-Code -- a simply image you can put on your web page. On Android (and other) devices, a QR code reader (best known and widely used on Android is Barcode Reader) utilizes the camera to take a picture from it, analyzes the coded content, and then offers an appropriate action. In case of a VCard, this would e.g. be to add it to your contact list -- exactly what you intended.

Of course you could simply export your contact data in VCard format for download (on opening that, the user would get the same choice to add the content to the contacts). You also could combine both, linking the QR-Code image to the downloadable VCard (make sure the file extension of the vcard file is set to .vcf, so the web server gets a chance to set the correct mime type -- otherwise it may be treated as "plain text" and opened inside the browser instead of being downloaded). This way a visitor could either use a barcode reader, or click on the code to download the VCard. Thus it even could be imported to apps on the PC: MS Outlook, Gnome Evolution, and others understand the VCard-Format as well.

Troubleshooting:

If you linked the VCard .vcf file for download, and it still only gets displayed in the browser window, here's how this can be fixed with Apache web server (solution by MrGlass -- thanks!):

Edit your Apache config (or, if you cannot access this, edit/create the .htaccess file in the directory your .vcf is stored) to contain the following segment:

<FilesMatch "\.vcf$">
  ForceType text/vcard
  Header set Content-Disposition attachment
</FilesMatch>
Izzy
  • 91,166
  • 73
  • 343
  • 943
  • 1
    I ended up doing something like this. One important note is that if you just stick the vcard file on a normal webhost, android will simply display the text in the browser. You need to force the content disposition header to attachment, so that its downloaded. I did this in apache by modifying my htaccess file. – MrGlass Jul 11 '12 at 14:26
  • @MrGlass thank you for this addition! Of course the web server must be configured accordingly. Probably adjusting the mimetype to reflect the correct value (text/vcard or text/x-vcard) would help as well. Maybe Apache didn't recognize it by the chosen file-ext -- did you name it something with .vcf (just added that part to my answer above)? – Izzy Jul 11 '12 at 14:44
  • 1
    No. I'm a web developer, and it always seems like apache never detects things like this automatically. <FilesMatch "\.vcf$"> ForceType text/vcard Header set Content-Disposition attachment </FilesMatch> in htaccess seems to fix things – MrGlass Jul 11 '12 at 14:51
  • Thank you for this hint! I just added it to the answer above. As in the comments formatting gets lost, please check whether I applied the line breaks correctly. Feel free to edit if I didn't ;) – Izzy Jul 11 '12 at 15:49
  • You got it right :) Now I have to see about makign it work with iPhone (boo hiss). Hard to make things work without a unit to test on :) – MrGlass Jul 11 '12 at 16:05
  • Why shouldn't this work with eye phone? VCard IMHO is a standard format, and QRCodes are as well -- which is why I recommended this combination. It not only works on Android, but also with Windows (Outlook), Linux (Evolution), and I suppose on MacOS and others as well. – Izzy Jul 11 '12 at 16:11
  • Oh, I agree, it should. I'm just getting reports that it isn't. No idea why yet - currently only method of testing is begging friends over IM or email. – MrGlass Jul 11 '12 at 17:14
  • Would be interesting what goes wrong there. Please update when you figured out. – Izzy Jul 11 '12 at 17:18
  • Check out this: http://apple.stackexchange.com/questions/26766/force-a-link-to-open-in-safari-instead-of-the-in-app-browser if I understand, the QR code app loads my URL using the embedded browser, which doesn't know how to handle a vcard, so it errors out. – MrGlass Jul 11 '12 at 19:37