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();
            Preconditions.checkArgument(payload.length > 0);
 
            /* 
             * 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 
             *