如何向nfc-explorer发送ndef消息?我尝试使用nfc资源管理器中的源代码,但始终会得到空的ndef消息。
答案 0 :(得分:0)
您有完整的演示实现here,并阅读了official documentation.
要回答您的问题,请发送消息:
public NdefMessage CreateNdefMessage (NfcEvent evt)
{
DateTime time = DateTime.Now;
var text = ("Beam me up!\n\n" + "Beam Time: " +
time.ToString ("HH:mm:ss"));
NdefMessage msg = new NdefMessage (
new NdefRecord[]{ CreateMimeRecord (
"application/com.example.android.beam",
Encoding.UTF8.GetBytes (text)) });
} };
return msg;
}
public NdefRecord CreateMimeRecord (String mimeType, byte [] payload)
{
byte [] mimeBytes = Encoding.UTF8.GetBytes (mimeType);
NdefRecord mimeRecord = new NdefRecord (
NdefRecord.TnfMimeMedia, mimeBytes, new byte [0], payload);
return mimeRecord;
}