Code example for NdefRecord

Methods: getPayload

0
        throw new IllegalArgumentException("Unknown TNF " + tnf);
    } 
 
    /** Parse and absolute URI record */ 
    private static UriRecord parseAbsolute(NdefRecord record) {
        byte[] payload = record.getPayload();
        Uri uri = Uri.parse(new String(payload, Charset.forName("UTF-8")));
        return new UriRecord(uri);
    } 
 
    /** Parse an well known URI record */ 
    private static UriRecord parseWellKnown(NdefRecord record) {
        Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.RTD_URI));
        byte[] payload = record.getPayload();
        /* 
         * payload[0] contains the URI Identifier Code, per the 
         * NFC Forum "URI Record Type Definition" section 3.2.2. 
         * 
         * payload[1]...payload[payload.length - 1] contains the rest of 
         * the URI. 
         */