Search code examples
androidemailnfcndef

How do I write email data to an NFC tags?


I tried the following code for writing text data, and it's a work fine

NdefRecord mimeRecord = NdefRecord.createMime("text/plain", remainingString.getBytes(Charset.forName("US-ASCII")));
ndef.writeNdefMessage(new NdefMessage(mimeRecord));

This for launch application.

NdefRecord[] records = {NdefRecord.createApplicationRecord("com.demo.abc"),

but i dont understand how to write email content.


Solution

  • for write email data

    NdefRecord mimeRecord = NdefRecord.createUri("mailto:" + "[email protected]" + "?body=" + "your email message");
    ndef.writeNdefMessage(new NdefMessage(mimeRecord));
    

    Understand carefully

    NdefRecord.createUri("mailto:" + "[email protected]") 
    

    write if you want to write only receiver email id into NFC tag

    NdefRecord.createUri("mailto:" + "[email protected]" + "?body=" + "your email message")
    

    write if you want to write receiver email id and message into NFC tag

    NdefRecord mimeRecord = NdefRecord.createUri("mailto:" + "[email protected]" + "?subject=" + "your email subject" + "&body=" + "your email message")
    

    write if you want to write receiver email id, email subject and message into NFC tag