How can I send ndef message to nfc-explorer? I try to use source code from nfc explorer but all the time get empty ndef message.
Asked
Active
Viewed 139 times
1 Answers
0
You have a full demo implementation here, and read the official documentation.
To answer your question, to send a message:
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;
}

Bruno Caceiro
- 7,035
- 1
- 26
- 45