Code example for NdefRecord

Methods: getTnf

0
     * 
     * @throws IllegalArgumentException if the NdefRecord is not a record 
     *         containing a URI. 
     */ 
    public static UriRecord parse(NdefRecord record) {
        short tnf = record.getTnf();
        if (tnf == NdefRecord.TNF_WELL_KNOWN) {
            return parseWellKnown(record);
        } else if (tnf == NdefRecord.TNF_ABSOLUTE_URI) {
            return parseAbsolute(record);
        } 
        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);
    }