本文整理汇总了Java中android.nfc.Tag.getTechList方法的典型用法代码示例。如果您正苦于以下问题:Java Tag.getTechList方法的具体用法?Java Tag.getTechList怎么用?Java Tag.getTechList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.nfc.Tag
的用法示例。
在下文中一共展示了Tag.getTechList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTagDiscovered
import android.nfc.Tag; //导入方法依赖的package包/类
@Override
public void onTagDiscovered(final Tag tag) {
Log.d(TAG, "Tag found: " + tag.toString());
Log.d(TAG, "Id: " + HexStrings.toHexString(tag.getId()));
for (String tech: tag.getTechList()) {
Log.d(TAG, "Tech: " + tech);
}
if (Arrays.asList(tag.getTechList()).contains("android.nfc.tech.IsoDep")) {
IsoDepApduInterface apduInterface;
try {
apduInterface = new IsoDepApduInterface(IsoDep.get(tag));
} catch (IOException e) {
fail(e.getMessage());
e.printStackTrace();
return;
}
dispatchLoadTask(apduInterface);
}
}
示例2: onNewIntent
import android.nfc.Tag; //导入方法依赖的package包/类
@Override
public void onNewIntent(Intent intent) {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String[] techList = tag.getTechList();
boolean haveMifareUltralight = false;
for (String tech : techList) {
if (tech.indexOf("MifareUltralight") >= 0) {
haveMifareUltralight = true;
break;
}
}
if (!haveMifareUltralight) {
Toast.makeText(this, "不支持MifareUltralight数据格式", Toast.LENGTH_SHORT).show();
return;
}
writeTag(tag);
}
示例3: onNewIntent
import android.nfc.Tag; //导入方法依赖的package包/类
@Override
public void onNewIntent(Intent intent) {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String[] techList = tag.getTechList();
boolean haveMifareUltralight = false;
for (String tech : techList) {
if (tech.indexOf("MifareUltralight") >= 0) {
haveMifareUltralight = true;
break;
}
}
if (!haveMifareUltralight) {
Toast.makeText(this, "不支持MifareUltralight数据格式", Toast.LENGTH_SHORT).show();
return;
}
String data = readTag(tag);
if (data != null)
Toast.makeText(this, data, Toast.LENGTH_SHORT).show();
}
示例4: resolveIntent
import android.nfc.Tag; //导入方法依赖的package包/类
private void resolveIntent(Intent data, boolean foregroundDispatch) {
this.setIntent(data);
scan = true;
String action = data.getAction();
if ((data.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { return; }
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)){
Tag tag = data.getParcelableExtra(NfcAdapter.EXTRA_TAG);
Date now = new Date();
if (foregroundDispatch && (now.getTime() - last_scan.getTime()) > 10000) { //10000 = 10sec
String[] techList = tag.getTechList();
String searchedTech = NfcV.class.getName();
// ###################### read Tag ######################
ProgressBar pb_scan;
pb_scan = (ProgressBar)findViewById(R.id.pb_reading_spin);
pb_scan.setVisibility(View.VISIBLE);
new NfcVReaderTask(this).execute(tag);
// ######################################################
}
}
}
示例5: handleIntent
import android.nfc.Tag; //导入方法依赖的package包/类
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;
}
}
}
示例6: onNewIntent
import android.nfc.Tag; //导入方法依赖的package包/类
@Override
public void onNewIntent(Intent intent)
{
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String[] techList =tag.getTechList();
boolean haveMifareUltralight = false;
for(String tech: techList)
{
if(tech.indexOf("MifareUltralight") >= 0)
{
haveMifareUltralight = true;
break;
}
}
if(!haveMifareUltralight)
{
Toast.makeText(this, "��֧��MifareUltralight���ݸ�ʽ", Toast.LENGTH_LONG).show();
return;
}
if(mWriteData.isChecked())
{
writeTag(tag);
}
else {
String data = readTag(tag);
if(data != null)
Toast.makeText(this, data, Toast.LENGTH_LONG).show();
}
}
示例7: onNewIntent
import android.nfc.Tag; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if(intent.getAction().equals(NfcAdapter.ACTION_NDEF_DISCOVERED) || intent.getAction().equals(NfcAdapter.ACTION_TECH_DISCOVERED)){
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String[] tagTechs = tag.getTechList();
if (Arrays.asList(tagTechs).contains(Ndef.class.getName())) {
writeKeyOnTag(tag, false);
} else if (Arrays.asList(tagTechs).contains(NdefFormatable.class.getName())) {
writeKeyOnTag(tag, true);
} else {
Toast.makeText(this, "Tag not supported", Toast.LENGTH_LONG).show();
}
}
}
示例8: handleIntent
import android.nfc.Tag; //导入方法依赖的package包/类
private void handleIntent(Intent intent) {
String action = intent.getAction();
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
Log.d("socialdiabetes", "NfcAdapter.ACTION_TECH_DISCOVERED");
// In case we would still use the Tech Discovered Intent
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
String[] techList = tag.getTechList();
String searchedTech = NfcV.class.getName();
new NfcVReaderTask().execute(tag);
}
}
示例9: repairTag
import android.nfc.Tag; //导入方法依赖的package包/类
/**
* Repairs the broken tag on HTC devices running Android 5.x
* <p/>
* "It seems, the reason of this bug in TechExtras of NfcA is null. However, TechList contains MifareClassic." -bildin
* For more information please refer to https://github.com/ikarus23/MifareClassicTool/issues/52#issuecomment-103797115
* <p/>
* Code source: https://github.com/ikarus23/MifareClassicTool/issues/52#issuecomment-104277445
*
* @param oTag The broken tag
* @return The fixed tag
*/
public static Tag repairTag(Tag oTag) {
if (oTag == null)
return null;
String[] sTechList = oTag.getTechList();
Parcel oParcel, nParcel;
oParcel = Parcel.obtain();
oTag.writeToParcel(oParcel, 0);
oParcel.setDataPosition(0);
int len = oParcel.readInt();
byte[] id = null;
if (len >= 0) {
id = new byte[len];
oParcel.readByteArray(id);
}
int[] oTechList = new int[oParcel.readInt()];
oParcel.readIntArray(oTechList);
Bundle[] oTechExtras = oParcel.createTypedArray(Bundle.CREATOR);
int serviceHandle = oParcel.readInt();
int isMock = oParcel.readInt();
IBinder tagService;
if (isMock == 0) {
tagService = oParcel.readStrongBinder();
} else {
tagService = null;
}
oParcel.recycle();
int nfca_idx = -1;
int mc_idx = -1;
for (int idx = 0; idx < sTechList.length; idx++) {
if (sTechList[idx].equals(NfcA.class.getName())) {
nfca_idx = idx;
} else if (sTechList[idx].equals(MifareClassic.class.getName())) {
mc_idx = idx;
}
}
if (nfca_idx >= 0 && mc_idx >= 0 && oTechExtras[mc_idx] == null) {
oTechExtras[mc_idx] = oTechExtras[nfca_idx];
} else {
return oTag;
}
nParcel = Parcel.obtain();
nParcel.writeInt(id.length);
nParcel.writeByteArray(id);
nParcel.writeInt(oTechList.length);
nParcel.writeIntArray(oTechList);
nParcel.writeTypedArray(oTechExtras, 0);
nParcel.writeInt(serviceHandle);
nParcel.writeInt(isMock);
if (isMock == 0) {
nParcel.writeStrongBinder(tagService);
}
nParcel.setDataPosition(0);
Tag nTag = Tag.CREATOR.createFromParcel(nParcel);
nParcel.recycle();
return nTag;
}