當前位置: 首頁>>代碼示例>>Java>>正文


Java Tag.getTechList方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:mDL-ILP,項目名稱:mDL-ILP,代碼行數:22,代碼來源:NFCConnection.java

示例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);
}
 
開發者ID:jopenbox,項目名稱:android-nfc,代碼行數:18,代碼來源:WriteMUActivity.java

示例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();
}
 
開發者ID:jopenbox,項目名稱:android-nfc,代碼行數:20,代碼來源:ReadMUActivity.java

示例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);
            // ######################################################
        }
    }
}
 
開發者ID:CMKlug,項目名稱:Liapp,代碼行數:27,代碼來源:MainActivity.java

示例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;
        }
    }
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:68,代碼來源:NfcShield.java

示例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();
}
  	
  	
  }
 
開發者ID:384401056,項目名稱:itheima,代碼行數:35,代碼來源:MifareultralightMainActivity.java

示例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();
        }
    }
}
 
開發者ID:OlivierGonthier,項目名稱:CryptoNFC,代碼行數:16,代碼來源:MainActivity.java

示例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);

    }
}
 
開發者ID:vicktor,項目名稱:FreeStyleLibre-NFC-Reader,代碼行數:14,代碼來源:Abbott.java

示例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;
}
 
開發者ID:pkern,項目名稱:kitcard-reader,代碼行數:79,代碼來源:MifareUtils.java


注:本文中的android.nfc.Tag.getTechList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。