How to get a vCard (.vcf file) into Android contacts from website
Asked Answered
L

8

13

I'm trying to add a vCard from a web link to the user's contact list on Android 2.2. When I direct the user to .vcf file, all I get is text output in the mobile browser. I have confirmed that the files is being transferred with MIME type text/v-card. This seems like it should be pretty simple to do. Any ideas?

Loosejointed answered 7/12, 2010 at 21:27 Comment(0)
C
5

AFAIK Android doesn't support vCard files out of the Box at least not until 2.2.

You could use the app vCardIO to read vcf files from your SD card and save to you contacts. So you have to save them on your SD card in the first place and import them afterwards.

vCardIO is also available trough the market.

Calceiform answered 7/12, 2010 at 21:38 Comment(1)
The best solution I have found is to force the download by setting the content-disposition to attachement for .vcf files in an Apache httpd.conf or .htaccess file. The user then has to open the file and they are asked how they want the contact info to be inserted into their contact list. This thread helped a lot: code.google.com/p/android/issues/detail?id=9215Loosejointed
H
5

Just to let you know: I just tried it using a vCard 2.1 file created according to the vCard 2.1 spec. I found that vCard 2.1, despite being an old version, already covered everything I needed, including a base64-encoded photo and international character sets.

It worked perfectly on my unmodified Android 4.1.1 device (Galaxy S3). It also worked on an old iPhone 3GS (iOS 5, via the Evernote app) and a coworker's unmodified old Android 2.1 device. You only need to set the Content-disposition to attachment as suggested above.

A minor problem was that I triggered the VCF download using a QR code, which I scanned with the Microsoft Tag app. That app told me Android couldn't handle the text/x-vcard media type (or just text/vcard, no matter). Once I opened the link in a Web browser (I tried Chrome and the Android default browser), it worked fine.

Hegarty answered 1/12, 2012 at 20:31 Comment(0)
H
4

There is now an import functionality on Android ICS 4.0.4.

First you must save your .vcf file on a storage (USB storage, or SDcard). Android will scan the selected storage to detect any .vcf file and will import it on the selected address book. The functionality is in the option menu of your contact list.

!Note: Be careful while doing this! Android will import EVERYTHING that is a .vcf in your storage. It's all or nothing, and the consequence can be trashing your address book.

Highland answered 22/6, 2012 at 9:0 Comment(0)
R
3

This can be used to download the file to your SD card Tested with Android version 2.3.3 and 4.0.3

======= php =========================

<?php
     // this php file (example saved as name is vCardDL.php) is placed in my html subdirectory
     //  
     header('Content-Type: application/octet-stream');
     // the above line is needed or else the .vcf file will be downloaded as a .htm file
     header('Content-disposition: attachment; filename="xxxxxxxxxx.vcf"');
     // 
     //header('Content-type: application/vcf'); remove this so android doesn't complain that it does not have a valid application
     readfile('../aaa/bbb/xxxxxxxxxx.vcf');
     //The above is the parth to where the file is located - if in same directory as the php, then just the file name
?>

======= html ========================

<FONT COLOR="#CC0033"><a href="vCardDL.php">Download vCARD</A></FONT>
Resonant answered 24/7, 2012 at 16:31 Comment(1)
Now you can use header("Content-type: text/x-vcard; charset=utf-8") for headerProspero
C
2

I'm running 2.2 and there is no change, reports from others on 2.3 say the same. Android (bug) does not handle a .vcf nor a link to such a file on a web page via port 80, neither via http headers or direct streaming. It just is NOT SUPPORTED AT ALL.

Chilung answered 29/3, 2011 at 17:4 Comment(2)
After trying to get this to work, this is my experience of Android, upto and including 4.0, as well....Quincentenary
I know this is an old answer but someone mights stumble upon it: Likely has to do with OEM versions and features they add.Anderton
M
2

I had problems with importing a VERSION:4.0 vcard file on Android 7 (LineageOS) with the standard Contacts app.

Since this is on the top search hits for "android vcard format not supported", I just wanted to note that I was able to import them with the Simple Contacts app (Play or F-Droid).

Masters answered 5/6, 2018 at 21:33 Comment(1)
Thank you for this! It worked great. Note that root is required to install this app from F-Droid as its a split APK. I imported my ProtonMail contacts using this methodOdessa
G
1

What i have also noticed is that you have to save the file as Unicode, UTF-8, no BOM in an Windows format with CRLF (Carriage Return, Line Feed). Because if you don't, the import will break. (Saying something about weird chars in the file)

Good luck :) Sid

Gristly answered 20/12, 2010 at 14:19 Comment(0)
E
0

It took me 2 days to find a php library for generating vcf files that is genuine you can try this library. It worked for my project hopefully it may work for yours too :)

Enthetic answered 9/3, 2022 at 7:53 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Amorita

© 2022 - 2024 — McMap. All rights reserved.