发送联系人.vcf文件联系人、文件、vcf

2023-09-03 14:51:51 作者:傲似你祖宗

我想使用蓝牙和电子邮件发送联系人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);
}
vcf文件电脑里怎么打开,有专门的软件吗 windows自带的除外

这是我的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卡中

 
精彩推荐
图片推荐