发送联系人.vcf文件 [英] Sending a contact .vcf file

查看:0
本文介绍了发送联系人.vcf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用蓝牙和电子邮件发送联系人VCF文件。我试过了,但总是出错。请帮帮忙。谢谢

这是我的sendBy蓝牙方法。

public void sendByBluetooth(){
    Intent intent = new Intent();  
    intent.setAction(Intent.ACTION_SEND);  
    intent.setType("image/png");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(storage_path) );  
    startActivity(intent);
}

这是我的emailContact方法。

public void emailContact() {     
    Intent sendIntent = new Intent(Intent.ACTION_SEND); 
    // Add attributes to the intent 
    sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    sendIntent.putExtra(Intent.EXTRA_SUBJECT,"subject line"); 
    sendIntent.putExtra(Intent.EXTRA_TEXT,"Body of email"); 
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(storage_path))); 
    sendIntent.setType("vnd.android.cursor.dir/email"); 

    startActivity(Intent.createChooser(sendIntent,"Email:"));       

}

请帮帮我!谢谢。

推荐答案

蓝牙类型可以设置为intent.setType("text/x-vcard");

public void sendByBluetooth(){
    Intent intent = new Intent();  
    intent.setAction(Intent.ACTION_SEND);  
    intent.setType("text/x-vcard");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(storage_path) );  
    startActivity(intent);
}

对于电子邮件,您可以使用

String filelocation="/mnt/sdcard/contacts.vcf";    
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// set the type to 'email'
emailIntent .setType("vnd.android.cursor.dir/email");
String to[] = {"asd@gmail.com"};
emailIntent .putExtra(Intent.EXTRA_EMAIL, to);
// the attachment
emailIntent .putExtra(Intent.EXTRA_STREAM, filelocation);
// the mail subject
emailIntent .putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(emailIntent , "Send email..."));

附注:.vcf文件应该在SD卡中

这篇关于发送联系人.vcf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆