NFC标签信息标签、信息、NFC

2023-09-04 23:43:24 作者:施主,贫僧是来化妞的

我有一个问题,有可能知道解释TH型NFC标签的,我读的code源?如果是的Mifare 1K或Ntag203或其他东西?

 保护无效onNewIntent(意向意图){
    的String [] techList = tag.getTechList();
    对于(字符串科技:techList){
        //我觉得必须在这里插入code
    }
}
 

解决方案

当你得到的标签,然后使用TechList你可以找到确切的标签类型。 这里是示例:

 保护无效onNewIntent(意向意图){
        getTagInfo(意向)
         }

私人无效getTagInfo(意向意图){
    标签标记= intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

    的String [] techList = tag.getTechList();
    的for(int i = 0; I< techList.length;我++){
        如果(techList [I] .equals(MifareClassic.class.getName())){

            MifareClassic mifareClassicTag = MifareClassic.get(标签);
            开关(mifareClassicTag.getType()){
            案例MifareClassic.TYPE_CLASSIC:
                //类型Clssic
                打破;
            案例MifareClassic.TYPE_PLUS:
                //型加
                打破;
            案例MifareClassic.TYPE_PRO:
                //类型临
                打破;
            }
        }否则如果(techList [I] .equals(MifareUltralight.class.getName())){
        //对于的Mifare超轻
            MifareUltralight mifareUlTag = MifareUltralight.get(标签);
            开关(mifareUlTag.getType()){
            案例MifareUltralight.TYPE_ULTRALIGHT:
                打破;
            案例MifareUltralight.TYPE_ULTRALIGHT_C:

                打破;
            }
        }否则如果(techList [I] .equals(IsoDep.class.getName())){
            //信息[1] =IsoDep;
            IsoDep isoDepTag = IsoDep.get(标签);

        }否则如果(techList [I] .equals(Ndef.class.getName())){
            Ndef.get(标签);

        }否则如果(techList [I] .equals(NdefFormatable.class.getName())){

            NdefFormatable ndefFormatableTag = NdefFormatable.get(标签);

        }
    }
}
 
三星 华为 小米支付为何物 NFC 全面科普

I have a question, it is possible know the code source of explain th type of tag NFC that I read? If is a Mifare 1k or Ntag203 or another else?

protected void onNewIntent(Intent intent){
    String[] techList = tag.getTechList();
    for(String tech:techList) {
        //I think must insert here the code         
    }
}

解决方案

When you get tag , Then using TechList you can find the exact tag Type. here is the sample:

 protected void onNewIntent(Intent intent){    
        getTagInfo(intent)
         }

private void getTagInfo(Intent intent) {
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

    String[] techList = tag.getTechList();
    for (int i = 0; i < techList.length; i++) {
        if (techList[i].equals(MifareClassic.class.getName())) {

            MifareClassic mifareClassicTag = MifareClassic.get(tag);
            switch (mifareClassicTag.getType()) {
            case MifareClassic.TYPE_CLASSIC:
                //Type Clssic
                break;
            case MifareClassic.TYPE_PLUS:
                //Type Plus
                break;
            case MifareClassic.TYPE_PRO:
                //Type Pro
                break;
            }
        } else if (techList[i].equals(MifareUltralight.class.getName())) {
        //For Mifare Ultralight
            MifareUltralight mifareUlTag = MifareUltralight.get(tag);
            switch (mifareUlTag.getType()) {
            case MifareUltralight.TYPE_ULTRALIGHT:
                break;
            case MifareUltralight.TYPE_ULTRALIGHT_C:

                break;
            }
        } else if (techList[i].equals(IsoDep.class.getName())) {
            // info[1] = "IsoDep";
            IsoDep isoDepTag = IsoDep.get(tag);

        } else if (techList[i].equals(Ndef.class.getName())) {
            Ndef.get(tag);

        } else if (techList[i].equals(NdefFormatable.class.getName())) {

            NdefFormatable ndefFormatableTag = NdefFormatable.get(tag);

        }
    }
}

 
精彩推荐