简体   繁体   English

如何从网站上获取Android密码的vCard(.vcf文件)

[英]How to get a vCard (.vcf file) into Android contacts from website

I'm trying to add a vCard from a web link to the user's contact list on Android 2.2. 我正在尝试将网络链接中的vCard添加到Android 2.2上的用户联系人列表中。 When I direct the user to .vcf file, all I get is text output in the mobile browser. 当我将用户定向到.vcf文件时,我得到的只是移动浏览器中的文本输出。 I have confirmed that the files is being transferred with MIME type text/v-card. 我已确认使用MIME类型text / v-card传输文件。 This seems like it should be pretty simple to do. 这看起来应该很简单。 Any ideas? 有任何想法吗?

AFAIK Android doesn't support vCard files out of the Box at least not until 2.2. AFAIK Android至少在2.2之前不支持开箱即用的vCard文件。

You could use the app vCardIO to read vcf files from your SD card and save to you contacts. 您可以使用app vCardIO从SD卡读取vcf文件并保存给您的联系人。 So you have to save them on your SD card in the first place and import them afterwards. 因此,您必须首先将它们保存在SD卡上,然后再导入它们。

vCardIO is also available trough the market. vCardIO也可以通过市场上市。

There is now an import functionality on Android ICS 4.0.4. Android ICS 4.0.4现在有导入功能。

First you must save your .vcf file on a storage (USB storage, or SDcard). 首先,您必须将.vcf文件保存在存储设备(USB存储设备或SD卡)上。 Android will scan the selected storage to detect any .vcf file and will import it on the selected address book. Android将扫描选定的存储以检测任何.vcf文件,并将其导入所选的地址簿。 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. Android将导入存储中的.vcf 一切 It's all or nothing, and the consequence can be trashing your address book. 这是全有或全无,后果可能会破坏你的地址簿。

Just to let you know: I just tried it using a vCard 2.1 file created according to the vCard 2.1 spec . 只是为了让您知道:我只是尝试使用根据vCard 2.1规范创建的vCard 2.1文件。 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. 我发现vCard 2.1虽然是旧版本,但已经涵盖了我需要的一切,包括base64编码的照片和国际字符集。

It worked perfectly on my unmodified Android 4.1.1 device (Galaxy S3). 它在我未经修改的Android 4.1.1设备(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. 它还可用于旧的iPhone 3GS(iOS 5,通过Evernote应用程序 )和同事未经修改的旧Android 2.1设备。 You only need to set the Content-disposition to attachment as suggested above. 您只需要按照上面的建议将Content-dispositionattachment

A minor problem was that I triggered the VCF download using a QR code , which I scanned with the Microsoft Tag app . 一个小问题是我使用QR代码触发了VCF下载,我使用Microsoft Tag应用程序扫描了该代码 That app told me Android couldn't handle the text/x-vcard media type (or just text/vcard , no matter). 该应用告诉我Android无法处理text/x-vcard媒体类型(或者只是text/vcard ,无论如何)。 Once I opened the link in a Web browser (I tried Chrome and the Android default browser), it worked fine. 一旦我在Web浏览器中打开链接(我尝试使用Chrome和Android默认浏览器),它运行正常。

This can be used to download the file to your SD card Tested with Android version 2.3.3 and 4.0.3 这可用于将文件下载到SD卡中使用Android版本2.3.3和4.0.3进行测试

======= php ========================= ======= 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 ======================== ======= html ========================

<FONT COLOR="#CC0033"><a href="vCardDL.php">Download vCARD</A></FONT>

I had problems with importing a VERSION:4.0 vcard file on Android 7 (LineageOS) with the standard Contacts app. 我在使用标准联系人应用程序在Android 7(LineageOS)上导入VERSION:4.0 vcard文件时遇到问题。

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 ). 由于这是“不支持android vcard格式”的热门搜索点击,我只想注意我能够使用简单联系人应用程序( PlayF-Droid )导入它们。

I'm running 2.2 and there is no change, reports from others on 2.3 say the same. 我正在运行2.2并没有任何变化,其他人在2.3上的报道也是如此。 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. Android(bug)不通过端口80处理.vcf或网页上此类文件的链接,也不通过http标头或直接流式处理。 It just is NOT SUPPORTED AT ALL. 它根本不支持。

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). 我还注意到你必须将文件保存为UnicodeUTF-8 ,没有带有CRLF (回车, CRLF行)的Windows格式的BOM Because if you don't, the import will break. 因为如果不这样做,导入将会中断。 (Saying something about weird chars in the file) (在文件中说一些奇怪的字符)

Good luck :) Sid 祝你好运:)希德

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM