|  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public NativeNfcReadHelper(Intent intent, Activity activity) { | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void setIntent(Intent intent) { | 
 |  |  |         this.tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 单例初始化 | 
 |  |  | 
 |  |  |         if (helper == null) { | 
 |  |  |             helper = new NativeNfcReadHelper(intent, activity); | 
 |  |  |         } | 
 |  |  |         helper.setIntent(intent); | 
 |  |  |         return helper; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public BaseUserCardCard getUserCardData(BaseUserCardCard userCardCard) { | 
 |  |  |         if (userCardCard!=null){ | 
 |  |  |         if (userCardCard != null) { | 
 |  |  |             BaseUserCardCard userCard = null; | 
 |  |  |             Map<String, List<byte[]>> map = new HashMap<>(); | 
 |  |  |             MifareClassic mfc = MifareClassic.get(tag); | 
 |  |  | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public String getCradType() { | 
 |  |  |  | 
 |  |  |         MifareClassic mfc = MifareClassic.get(tag); | 
 |  |  |         if (null != mfc) { | 
 |  |  |             try { | 
 |  |  | 
 |  |  |                 mfc.connect(); | 
 |  |  |                 //获取当前卡号 | 
 |  |  |                 boolean isOpen = false; | 
 |  |  |                 for (int i = 0; i < listKeyA.size(); i++) { | 
 |  |  |                     if (mfc.authenticateSectorWithKeyA(0, listKeyA.get(i))) { | 
 |  |  |                 if (!listKeyA.isEmpty()) { | 
 |  |  |                     for (int i = 0; i < listKeyA.size(); i++) { | 
 |  |  |                         if (mfc.authenticateSectorWithKeyA(0, listKeyA.get(i))) { | 
 |  |  |                             isOpen = true; | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } else if (!listA_PS.isEmpty()) { | 
 |  |  |                     if (mfc.authenticateSectorWithKeyA(0, defauleKey)) { | 
 |  |  |                         isOpen = true; | 
 |  |  |                         break; | 
 |  |  |                     } else if (mfc.authenticateSectorWithKeyA(0, listA_PS.get(0))) { | 
 |  |  |                         isOpen = true; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (isOpen) { | 
 |  |  |                     int bIndex = mfc.sectorToBlock(0); | 
 |  |  |                     byte[] data = mfc.readBlock(bIndex + 0); | 
 |  |  | 
 |  |  |         return ""; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public String getCardNumberNoClose() { | 
 |  |  |         MifareClassic mfc = MifareClassic.get(tag); | 
 |  |  |         if (null != mfc) { | 
 |  |  |             try { | 
 |  |  |                 mfc.connect(); | 
 |  |  |                 //获取当前卡号 | 
 |  |  |                 boolean isOpen = false; | 
 |  |  |                 if (!listKeyA.isEmpty()) { | 
 |  |  |                     for (int i = 0; i < listKeyA.size(); i++) { | 
 |  |  |                         if (mfc.authenticateSectorWithKeyA(0, listKeyA.get(i))) { | 
 |  |  |                             isOpen = true; | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } else if (!listA_PS.isEmpty()) { | 
 |  |  |                     if (mfc.authenticateSectorWithKeyA(0, defauleKey)) { | 
 |  |  |                         isOpen = true; | 
 |  |  |                     } else if (mfc.authenticateSectorWithKeyA(0, listA_PS.get(0))) { | 
 |  |  |                         isOpen = true; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (isOpen) { | 
 |  |  |                     int bIndex = mfc.sectorToBlock(0); | 
 |  |  |                     byte[] data = mfc.readBlock(bIndex + 0); | 
 |  |  |                     if (data != null && data.length > 0) { | 
 |  |  |                         String hex = HexUtil.bytesToHex(Arrays.copyOfRange(data, 0, 4)); | 
 |  |  |                         hex = HexUtil.spaceHex(hex); | 
 |  |  |                         hex = HexUtil.HighLowHex(hex); | 
 |  |  |                         Log.i("NFCWreatActivity", "hex===" + hex); | 
 |  |  |                         return hex.toUpperCase(); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } catch (IOException e) { | 
 |  |  |                 Log.i("NFCWreatActivity", e.toString()); | 
 |  |  |                 return BaseCommon.CARD_TYPE_ERROR1; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return ""; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取卡片类型和卡号 | 
 |  |  |      * |