Code example for NdefRecord

     * @param view The textView that contains the text to be turned into a message. 
     * @return Returns a new NdefMessage from the text. 
    public NdefMessage getTextViewAsNdef(TextView view) {
        byte[] textBytes = view.getText().toString().getBytes();
        NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeType.getBytes(),
                new byte[] {}, textBytes);
        message = new NdefMessage(new NdefRecord[] {
        return message;
     * a helper method to set a string from the payload of a single message. 
    public void setPayloadString() { 
        payloadString = new String(message.getRecords()[0].getPayload());
Experience pair programming with AI  Get Codota for Java