Java Code Examples for android.nfc.NdefRecord#TNF_UNKNOWN
The following examples show how to use
android.nfc.NdefRecord#TNF_UNKNOWN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZannenNfcWriter.java From effective_android_sample with Apache License 2.0 | 5 votes |
NdefMessage[] getNdefMessages(Intent intent) { // Parse the intent NdefMessage[] msgs = null; String action = intent.getAction(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); if (rawMsgs != null) { msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i < rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; } } else { // Unknown tag type byte[] empty = new byte[] {}; NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty); NdefMessage msg = new NdefMessage(new NdefRecord[] { record }); msgs = new NdefMessage[] { msg }; } } else { Log.d(TAG, "Unknown intent."); finish(); } return msgs; }
Example 2
Source File: UnknownRecord.java From effective_android_sample with Apache License 2.0 | 4 votes |
@Override public NdefRecord getNdefRecord() { return new NdefRecord(NdefRecord.TNF_UNKNOWN, EMPTY, id != null ? id : EMPTY, payload != null ? payload : EMPTY); }
Example 3
Source File: Record.java From effective_android_sample with Apache License 2.0 | 4 votes |
/** * 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; }