| | |
| | | private static NativeNfcWriteHelper helper; |
| | | |
| | | public NativeNfcWriteHelper(Intent intent, Activity activity) { |
| | | } |
| | | |
| | | public void setIntent(Intent intent) { |
| | | this.tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); |
| | | } |
| | | |
| | |
| | | if (helper == null) { |
| | | helper = new NativeNfcWriteHelper(intent, activity); |
| | | } |
| | | helper.setIntent(intent); |
| | | return helper; |
| | | } |
| | | |
| | |
| | | * @param |
| | | */ |
| | | @Override |
| | | public boolean writeUserData(BaseUserCardCard userCard) { |
| | | public boolean writeUserData(BaseUserCardCard userCard, int sector) { |
| | | if (userCard != null) { |
| | | int a = 1; |
| | | int a = sector; |
| | | try { |
| | | MifareClassic mfc = MifareClassic.get(tag); |
| | | if (null != mfc) { |
| | |
| | | @Override |
| | | public boolean writeData(byte[] str, int a, int b, NFCCallBack callBack) { |
| | | Log.i("NFCWreatActivity", "writeData: a=" + a + " b=" + b); |
| | | if (str.length <= 16) { |
| | | if (str.length == 16) { |
| | | try { |
| | | MifareClassic mfc = MifareClassic.get(tag); |
| | | if (null != mfc) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (isOpen) { |
| | | int bIndex = mfc.sectorToBlock(a); |
| | | //写卡 |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | callBack.isSusses(false, a + "扇区写卡报错" + e.getMessage()); |
| | | return false; |
| | | } |
| | | } else { |
| | | callBack.isSusses(false, a + "扇区写卡报错,byte数组大小不为16"); |
| | | } |
| | | return false; |
| | | } |