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?
7 回答
AFAIK Android 至少在 2.2 之前不支持开箱即用的 vCard 文件。
您可以使用应用程序vCardIO从您的 SD 卡中读取 vcf 文件并将其保存到您的联系人中。因此,您必须首先将它们保存在 SD 卡上,然后再导入它们。
vCardIO 也可以通过市场获得。
Android ICS 4.0.4 现在有一个导入功能。
首先,您必须将.vcf
文件保存在存储设备(USB 存储设备或 SD 卡)上。Android 将扫描选定的存储以检测任何.vcf
文件并将其导入选定的地址簿。该功能位于联系人列表的选项菜单中。
!注意: 这样做时要小心! Android 将导入您存储中的所有内容。.vcf
要么全有,要么全无,其后果可能是破坏您的通讯录。
只是为了让您知道:我刚刚使用根据vCard 2.1 规范创建的 vCard 2.1 文件进行了尝试。我发现 vCard 2.1 尽管是旧版本,但已经涵盖了我需要的所有内容,包括 base64 编码的照片和国际字符集。
它在我未经修改的 Android 4.1.1 设备 (Galaxy S3) 上完美运行。它还可以在旧 iPhone 3GS(iOS 5,通过Evernote 应用程序)和同事未经修改的旧 Android 2.1 设备上运行。您只需要按照上面的建议设置Content-disposition
为attachment
。
一个小问题是我使用二维码触发了 VCF 下载,我使用Microsoft Tag 应用程序扫描了二维码。该应用程序告诉我Android无法处理text/x-vcard
媒体类型(或者只是text/vcard
,无论如何)。在 Web 浏览器中打开链接后(我尝试了 Chrome 和 Android 默认浏览器),它运行良好。
这可用于将文件下载到您的 SD 卡 使用 Android 版本 2.3.3 和 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>
我正在运行 2.2 并且没有任何变化,其他人在 2.3 上的报告也是如此。Android(错误)不处理 .vcf 或通过端口 80 处理网页上此类文件的链接,无论是通过 http 标头还是直接流式传输。它根本不被支持。
我还注意到,您必须使用(回车,换行)将文件另存为WindowsUnicode
格式。因为如果你不这样做,导入就会中断。(说一下文件中奇怪的字符)UTF-8
BOM
CRLF
祝你好运:) 希德