Code example for NdefRecord

Methods: getPayload, getTnf, getType

0
        return mLanguageCode;
    } 
 
    // TODO: deal with text fields which span multiple NdefRecords 
    public static TextRecord parse(NdefRecord record) {
        Preconditions.checkArgument(record.getTnf() == NdefRecord.TNF_WELL_KNOWN);
        Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.RTD_TEXT));
        try { 
            byte[] payload = record.getPayload();
            /* 
             * payload[0] contains the "Status Byte Encodings" field, per the 
             * NFC Forum "Text Record Type Definition" section 3.2.1. 
             * 
             * bit7 is the Text Encoding Field. 
             * 
             * if (Bit_7 == 0): The text is encoded in UTF-8 if (Bit_7 == 1): 
             * The text is encoded in UTF16 
             * 
             * Bit_6 is reserved for future use and must be set to zero. 
             * 
             * Bits 5 to 0 are the length of the IANA language code.