所以现在我有一个 NFC 项目,我写了一个 vcard 文件,但输出不是我想要的,这是代码:
private NdefMessage getNoteAsNdef() {
// byte[] textBytes = mName.getText().toString().getBytes();
// EditText tName = mName;
// EditText tNumber = mNumber;
String nameVcard = "BEGIN:VCARD" +"\n"+ "VERSION:2.1" +"\n" + "N:;" + (EditText) findViewById(R.id.mName) + "\n" +"ORG:"+"\n"+ "TEL;WORK:" +(EditText) findViewById(R.id.mNumber)+ "\n" + "END:VCARD";
byte[] uriField = nameVcard.getBytes(Charset.forName("US-ASCII"));
byte[] textBytes = new byte[uriField.length + 1];;
System.arraycopy(uriField, 0, textBytes, 1, uriField.length);
NdefRecord textRecord = new NdefRecord(
NdefRecord.TNF_MIME_MEDIA, "text/x-vcard".getBytes(), new byte[0], textBytes);
return new NdefMessage(new NdefRecord[] {
textRecord
});
}
输出是某种奇怪的词,总是有一个“@”
没看懂,有什么要补充的吗?