當前位置: 首頁>>代碼示例>>Java>>正文


Java NdefRecord.TNF_EMPTY屬性代碼示例

本文整理匯總了Java中android.nfc.NdefRecord.TNF_EMPTY屬性的典型用法代碼示例。如果您正苦於以下問題:Java NdefRecord.TNF_EMPTY屬性的具體用法?Java NdefRecord.TNF_EMPTY怎麽用?Java NdefRecord.TNF_EMPTY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.nfc.NdefRecord的用法示例。


在下文中一共展示了NdefRecord.TNF_EMPTY屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: eraseTag

private void eraseTag(CallbackContext callbackContext) throws JSONException {
    Tag tag = savedIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    NdefRecord[] records = {
        new NdefRecord(NdefRecord.TNF_EMPTY, new byte[0], new byte[0], new byte[0])
    };
    writeNdefMessage(new NdefMessage(records), tag, callbackContext);
}
 
開發者ID:theGreatWhiteShark,項目名稱:mensacard-hack,代碼行數:7,代碼來源:NfcPlugin.java

示例2: parseTnf

private static String parseTnf(Context ctx, NdefRecord record) {
    short tnf = record.getTnf();
    switch(tnf) {
        case NdefRecord.TNF_ABSOLUTE_URI:
            return ctx.getString(R.string.tnf_abs_uri);
        case NdefRecord.TNF_EMPTY:
            return ctx.getString(R.string.tnf_empty);
        case NdefRecord.TNF_EXTERNAL_TYPE:
            return ctx.getString(R.string.tnf_external);
        case NdefRecord.TNF_MIME_MEDIA:
            return ctx.getString(R.string.tnf_mime_media);
        case NdefRecord.TNF_UNCHANGED:
            return ctx.getString(R.string.tnf_unchanged);
        case NdefRecord.TNF_WELL_KNOWN:
            return ctx.getString(R.string.tnf_well_known);
        default:
            return ctx.getString(R.string.tnf_unknown);
    }
}
 
開發者ID:TapTrack,項目名稱:TappyBLE,代碼行數:19,代碼來源:TcmpMessageDescriptor.java

示例3: toNfcRecord

/**
 * Converts android.nfc.NdefRecord to mojo NfcRecord
 */
private static NfcRecord toNfcRecord(NdefRecord ndefRecord)
        throws UnsupportedEncodingException {
    switch (ndefRecord.getTnf()) {
        case NdefRecord.TNF_EMPTY:
            return createEmptyRecord();
        case NdefRecord.TNF_MIME_MEDIA:
            return createMIMERecord(
                    new String(ndefRecord.getType(), "UTF-8"), ndefRecord.getPayload());
        case NdefRecord.TNF_ABSOLUTE_URI:
            return createURLRecord(ndefRecord.toUri());
        case NdefRecord.TNF_WELL_KNOWN:
            return createWellKnownRecord(ndefRecord);
    }
    return null;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:18,代碼來源:NfcTypeConverter.java

示例4: getRecordTypeCategory

private DataReply getRecordTypeCategory(int recordNumber) {
    DataReply dataReply = new DataReply();
    int type = UNKNOWN_TYPE;
    if (currentTag != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
            Ndef ndef = Ndef.get(currentTag);
            if (ndef != null) {
                if (ndef.getCachedNdefMessage() != null)
                    if (ndef.getCachedNdefMessage().getRecords().length > recordNumber) {
                        NdefRecord record = ndef.getCachedNdefMessage().getRecords()[recordNumber];
                        int tnfType = record.getTnf();
                        switch (tnfType) {
                            case NdefRecord.TNF_EMPTY:
                                type = EMPTY_TYPE;
                                break;
                            case NdefRecord.TNF_WELL_KNOWN:
                                if (Arrays.equals(record.getType(), NdefRecord.RTD_URI)) {
                                    type = URI_TYPE;
                                } else if (Arrays.equals(record.getType(), NdefRecord.RTD_TEXT)) {
                                    type = TEXT_TYPE;
                                } else {
                                    type = UNSUPPORTED_TYPE;
                                }
                                break;
                            case NdefRecord.TNF_ABSOLUTE_URI:
                                type = ABSOLUTE_URI_TYPE;
                                break;
                            case NdefRecord.TNF_EXTERNAL_TYPE:
                                type = EXTERNAL_TYPE;
                                break;
                            case NdefRecord.TNF_MIME_MEDIA:
                                type = MIME_MEDIA_TYPE;
                                break;
                            case NdefRecord.TNF_UNCHANGED:
                                type = UNCHANGED_TYPE;
                                break;
                            case NdefRecord.TNF_UNKNOWN:
                                type = UNKNOWN_TYPE;
                                break;
                            default:
                                type = UNKNOWN_TYPE;
                                break;
                        }
                    } else {
                        dataReply.setError(RECORD_NOT_FOUND);
                        return dataReply;
                    }
                else {
                    dataReply.setError(RECORD_NOT_FOUND);
                    return dataReply;
                }
            } else {
                dataReply.setError(TAG_READING_ERROR);
                return dataReply;
            }
            try {
                if (ndef != null) ndef.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    dataReply.setIntegerData(type);
    return dataReply;
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:65,代碼來源:NfcShield.java

示例5: emptyNdefMessage

/**
 * Constructs empty NdefMessage
 */
public static NdefMessage emptyNdefMessage() {
    return new NdefMessage(new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null));
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:6,代碼來源:NfcTypeConverter.java

示例6: getNdefRecord

@Override
public NdefRecord getNdefRecord() {
	return new NdefRecord(NdefRecord.TNF_EMPTY, EMPTY, id != null ? id : EMPTY, EMPTY);
}
 
開發者ID:kemerelab,項目名稱:RodentDBS,代碼行數:4,代碼來源:EmptyRecord.java

示例7: parse

/**
    * Parse a byte-based {@link NdefRecord} into a high-level {@link Record}.
    * 
    * @param ndefRecord record to parse
    * @return corresponding {@link Record} subclass - {@link UnsupportedRecord} is not known.
    * @throws FormatException if known record type cannot be parsed
    */

public static Record parse(NdefRecord ndefRecord) throws FormatException {
	short tnf = ndefRecord.getTnf();
	
	Record record = null;
	switch (tnf) {
       case NdefRecord.TNF_EMPTY: {
       	record = EmptyRecord.parse(ndefRecord);
       	
       	break;
       }
       case NdefRecord.TNF_WELL_KNOWN: {
       	record = parseWellKnown(ndefRecord);
       	
       	break;
       }
       case NdefRecord.TNF_MIME_MEDIA: {
       	record = MimeRecord.parse(ndefRecord);
       	
       	break;
       }
       case NdefRecord.TNF_ABSOLUTE_URI: {
       	record = AbsoluteUriRecord.parse(ndefRecord);
       	
       	break;
       }
       case NdefRecord.TNF_EXTERNAL_TYPE: {
       	record = ExternalTypeRecord.parse(ndefRecord);

       	break;
       }
       case NdefRecord.TNF_UNKNOWN: {
       	record = UnknownRecord.parse(ndefRecord);
       	
       	break;
       }
       /*
       case NdefRecord.TNF_UNCHANGED: {
       	throw new IllegalArgumentException("Chunked records no supported"); // chunks are abstracted away by android so should never happen
       }
       */
       	
	}

	if(record == null) { // pass through
		record = UnsupportedRecord.parse(ndefRecord);
	}
	
	if(ndefRecord.getId().length > 0) {
		record.setId(ndefRecord.getId());
	}
	
	return record;
}
 
開發者ID:kemerelab,項目名稱:RodentDBS,代碼行數:61,代碼來源:Record.java


注:本文中的android.nfc.NdefRecord.TNF_EMPTY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。