本文整理汇总了Java中android.nfc.NfcAdapter.ACTION_TECH_DISCOVERED属性的典型用法代码示例。如果您正苦于以下问题:Java NfcAdapter.ACTION_TECH_DISCOVERED属性的具体用法?Java NfcAdapter.ACTION_TECH_DISCOVERED怎么用?Java NfcAdapter.ACTION_TECH_DISCOVERED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.nfc.NfcAdapter
的用法示例。
在下文中一共展示了NfcAdapter.ACTION_TECH_DISCOVERED属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pendingIntent = PendingIntent.getActivity(
this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
IntentFilter mifare = new IntentFilter((NfcAdapter.ACTION_TECH_DISCOVERED));
filters = new IntentFilter[] { mifare };
techs = new String[][] { new String[] {NfcA.class.getName() } };
if(adapter==null)
{
adapter = NfcAdapter.getDefaultAdapter(this);
}
imageView = (ImageView) findViewById(R.id.imageView);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation rotation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotation);
imageView.startAnimation(rotation);
}
});
}
示例2: 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;
}
}
}