Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

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>
share|improve this answer
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
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.