Code example for NdefRecord

Methods: getPayloadgetType

0
        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. 
         */ 
        String prefix = URI_PREFIX_MAP.get(payload[0]);
        byte[] fullUri =
            Bytes.concat(prefix.getBytes(Charset.forName("UTF-8")), Arrays.copyOfRange(payload, 1,
                payload.length));
        Uri uri = Uri.parse(new String(fullUri, Charset.forName("UTF-8")));
        return new UriRecord(uri);
Experience pair programming with AI  Get Codota for Java