本文整理匯總了Java中android.nfc.NdefRecord.TNF_UNKNOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Java NdefRecord.TNF_UNKNOWN屬性的具體用法?Java NdefRecord.TNF_UNKNOWN怎麽用?Java NdefRecord.TNF_UNKNOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.nfc.NdefRecord
的用法示例。
在下文中一共展示了NdefRecord.TNF_UNKNOWN屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNdefMessages
/**
* Récupère la lise des NdefMessages contenus dans le tag
*/
public static NdefMessage[] getNdefMessages(Intent intent){
NdefMessage[] messages;
// On récupère les objets
Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
if (rawMsgs != null) {
messages = new NdefMessage[rawMsgs.length];
for (int i = 0; i < rawMsgs.length; i++) {
// On cast les les objets en NdefMessage
messages[i] = (NdefMessage) rawMsgs[i];
}
} else {
// Type du tag inconnu
byte[] empty = new byte[] {};
// On crée un faux NdefMessage qui a contenu vide
NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty);
NdefMessage msg = new NdefMessage(new NdefRecord[] {record});
messages = new NdefMessage[] {msg};
}
return messages;
}
示例2: getNdefMessages
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;
}
示例3: getNdefMessages
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) {
Log.d(TAG, "known tag type. (I think)");
msgs = new NdefMessage[rawMsgs.length];
for (int i = 0; i < rawMsgs.length; i++) {
msgs[i] = (NdefMessage) rawMsgs[i];
}
} else {
Log.d(TAG, "Unknown tag type.");
// 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;
}
示例4: resolveIntent
void resolveIntent(Intent intent) {
// Parse the intent
String action = intent.getAction();
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
// When a tag is discovered we send it to the service to be save. We
// include a PendingIntent for the service to call back onto. This
// will cause this activity to be restarted with onNewIntent(). At
// that time we read it from the database and view it.
Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
NdefMessage[] msgs;
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};
}
// Setup the views
setTitle(R.string.title_scanned_tag);
buildTagViews(msgs);
} else {
Log.e(TAG, "Unknown intent " + intent);
finish();
return;
}
}
示例5: resolveIntent
void resolveIntent(Intent intent) {
// Parse the intent
String action = intent.getAction();
Log.i("ACTION", ""+action);
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
// When a tag is discovered we send it to the service to be save. We
// include a PendingIntent for the service to call back onto. This
// will cause this activity to be restarted with onNewIntent(). At
// that time we read it from the database and view it.
Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
NdefMessage[] msgs;
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};
}
// Setup the views
//setTitle(new String(msgs[0].getRecords()[0].getPayload()));
buildTagViews(msgs);
} else {
Log.e(TAG, "Unknown intent " + intent);
finish();
return;
}
}
示例6: 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;
}
示例7: getNdefRecord
@Override
public NdefRecord getNdefRecord() {
return new NdefRecord(NdefRecord.TNF_UNKNOWN, EMPTY, id != null ? id : EMPTY, payload != null ? payload : EMPTY);
}
示例8: 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;
}