什么是邮件和电话号码的正确MIME类型?
我目前正在NFC NFC上使用NdefRecords NFC标签。要存储名片(vCard),使用此MIME类型是不够的:什么是邮件和电话号码的正确MIME类型?
text/vcard
但什么是MIME类型的电子邮件地址或电话号码?
或者,您可以提出一个很好的解决方案,将电话号码和电子邮件地址写入NFC标签吗?
存储电话号码(拨打电话)和电子邮件链接(不通过整个名片)的正确方法是使用URI记录。
对于电话呼叫(对数431234567),该URI将
tel:+431234567
在Android上,你可以创建一个包含该URI使用
NdefRecord callUri = NdefRecord.createUri("tel:+431234567");
的NDEF纪录或发送SMS:
NdefRecord callUri = NdefRecord.createUri("sms:+431234567?body=MyMessage");
对于电子邮件(到[email protected]),URI将是
mailto:[email protected]
在Android上,你可以创建一个包含该URI使用
NdefRecord mailtoUri = NdefRecord.createUri("mailto:[email protected]");
顺便说一句的NDEF记录。除了简单的收件人地址之外,URI方案(以及URI方案)还支持其他参数,如subject
以指定邮件主题,并支持body
以指定邮件文本(请参阅相关的RFC以获取对这些功能的完整描述,但请注意,Android不支持所有这些)。例如
NdefRecord mailtoUri = NdefRecord.createUri("mailto:[email protected]?subject=mysubject&body=mytext");
将创建一个NDEF记录一个现成的电子邮件消息[email protected]的主题为“mysubject”和邮件正文“mytext的内容”。
是的,这工作正常。但对于邮件其预先填写只有mailto部分,我还需要预先填写主题和身体section.any建议?请等待您的回复。 – 2014-10-08 08:00:27
您是否尝试过使用'mailto:[email protected]?subject = something&body = mytext'? – 2014-10-08 08:56:04
酷了它的工作正常,答案接受 – 2014-10-08 09:33:58
这是我的代码,我用它来发送电子邮件文本和多个附件:
private final void sendEmailWithMultipleAttachments
(
final String[] to, final String[] cc, final String[] bcc,
final String subject, final String body, final List<String> filePaths
) throws ActivityNotFoundException
{
final Intent tnt =
new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
////tnt.setType("plain/text");
//tnt.setType("text/plain");
//tnt.setType("message/rfc822");
//tnt.setType("text/xml");
tnt.setType("*/*");
tnt.putExtra(android.content.Intent.EXTRA_EMAIL, to);
//tnt.putExtra(android.content.Intent.EXTRA_CC, cc);
//tnt.putExtra(android.content.Intent.EXTRA_BCC, bcc);
tnt.putExtra(Intent.EXTRA_SUBJECT, subject);
//tnt.putExtra(Intent.EXTRA_TEXT, body);
if (filePaths != null)
{
// It has to be an ArrayList
final ArrayList<Uri> URIs = new ArrayList<Uri>();
// Convert from paths to Android friendly Parcelable URIs
for (final String file : filePaths)
{
final File fileIn = new File(file);
if (fileIn.exists())
{
final Uri u = Uri.fromFile(fileIn);
URIs.add(u);
}
}
tnt.putParcelableArrayListExtra(Intent.EXTRA_STREAM, URIs);
}
// TEST ONLY:
/*
System.out.println("to : " + to[0]);
System.out.println("subject: " + subject);
System.out.println("file/s : " + filePaths.size());
*/
// It has to be "this"!!
//this.startActivity(Intent.createChooser(tnt, ""));
//this.startActivity(Intent.createChooser(tnt, "Choose an eMail Client"));
/*
// Without the "Use this actios as default" checkbox
startActivity
(
Intent.createChooser
(
tnt, getString(R.string.choose)
)
);
*/
// With the "Use this actios as default" checkbox
startActivity(tnt);
}
这很好,我也想知道recordNFC = new NdefRecord(????); – 2014-10-01 14:15:09
我对NFC/NDEF没有任何线索 – 2014-10-01 14:20:45
有了NFC,您可以使用MIME类型虚拟卡。我们使用了例如“文字/ x-vCard”,它工作正常,甚至包括一张照片。
'text/plain'呢? – 2014-10-01 13:54:03
text/plain仅适用于普通文本。如果我使用文本/普通NFC阅读器作为普通文本阅读它不应该 – 2014-10-01 13:56:52
我使用'*/*'为eMails,因为我使用附件 – 2014-10-01 13:58:55