本文整理匯總了Java中android.nfc.NfcAdapter.ACTION_TAG_DISCOVERED屬性的典型用法代碼示例。如果您正苦於以下問題:Java NfcAdapter.ACTION_TAG_DISCOVERED屬性的具體用法?Java NfcAdapter.ACTION_TAG_DISCOVERED怎麽用?Java NfcAdapter.ACTION_TAG_DISCOVERED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.nfc.NfcAdapter
的用法示例。
在下文中一共展示了NfcAdapter.ACTION_TAG_DISCOVERED屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleIntent
public void handleIntent(Intent intent) {
String action = intent.getAction();
if (action == null) return;
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
if (tag == null) {
sendError(TAG_READING_ERROR);
}else {
resetTechnologyFlags();
switch (action) {
case NfcAdapter.ACTION_NDEF_DISCOVERED:
setCurrentTag(tag);
if (!getNdefMaxSize().hasError() && !getTagId().hasError()) {
isTagSupported = true;
isNdef_Flag = true;
displayData();
sendNewTagFrame();
} else {
sendError(TAG_READING_ERROR);
}
break;
case NfcAdapter.ACTION_TECH_DISCOVERED:
setCurrentTag(tag);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
String[] techList = tag.getTechList();
for (String tech : techList) {
if (!isTagSupported) {
if (Ndef.class.getName().equals(tech)) {
DataReply maxSize = getNdefMaxSize();
if (!maxSize.hasError() && !getTagId().hasError()) {
isNdef_Flag = false;
isTagSupported = true;
DataReply recordCount = getNdefRecordCount();
if (recordCount.getIntegerData() > 0 && recordCount.getIntegerData() < 256) {
isNdef_Flag = true;
displayData();
sendNewTagFrame();
}else if (recordCount.getIntegerData() == 0){
sendNewEmptyTagFrame();
}else if(recordCount.getError() != 0){
sendError(recordCount.getError());
}
} else if (maxSize.hasError()){
sendError(maxSize.getError());
}
} else if (NdefFormatable.class.getName().equals(tech)) {
/*isNdef_Flag = false;
isTagSupported = true;
if (!getNdefMaxSize().hasError()&& !getTagId().hasError()) {
sendNewEmptyTagFrame();
displayData();
} else {
sendError(TAG_READING_ERROR);
}*/
}
} else
break;
}
if (!isTagSupported)
sendError(TAG_NOT_SUPPORTED);
}
break;
case NfcAdapter.ACTION_TAG_DISCOVERED:
setCurrentTag(tag);
break;
}
}
}