本文整理匯總了Java中org.ndeftools.UnsupportedRecord類的典型用法代碼示例。如果您正苦於以下問題:Java UnsupportedRecord類的具體用法?Java UnsupportedRecord怎麽用?Java UnsupportedRecord使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UnsupportedRecord類屬於org.ndeftools包,在下文中一共展示了UnsupportedRecord類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nfcIntentDetected
import org.ndeftools.UnsupportedRecord; //導入依賴的package包/類
@Override
public void nfcIntentDetected(Intent intent, String action) {
Log.d(TAG, "nfcIntentDetected: " + action);
Parcelable[] messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
if (messages != null) {
NdefMessage[] ndefMessages = new NdefMessage[messages.length];
for (int i = 0; i < messages.length; i++) {
ndefMessages[i] = (NdefMessage) messages[i];
}
if(ndefMessages.length > 0) {
// read as much as possible
Message message = new Message();
for (int i = 0; i < messages.length; i++) {
NdefMessage ndefMessage = (NdefMessage) messages[i];
for(NdefRecord ndefRecord : ndefMessage.getRecords()) {
try {
message.add(Record.parse(ndefRecord));
} catch (FormatException e) {
// if the record is unsupported or corrupted, keep as unsupported record
message.add(UnsupportedRecord.parse(ndefRecord));
}
}
}
readNdefMessage(message);
} else {
readEmptyNdefMessage();
}
} else {
readNonNdefMessage();
}
}