左晓为主开发手持机充值管理机
zuojincheng
2025-03-26 1bc1acff2127d61b359800096ad5b904370d9176
baselibrary/src/main/java/com/dayu/baselibrary/tools/nfc/NativeNfcWriteHelper.java
@@ -24,6 +24,9 @@
    private static NativeNfcWriteHelper helper;
    public NativeNfcWriteHelper(Intent intent, Activity activity) {
    }
    public void setIntent(Intent intent) {
        this.tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    }
@@ -37,6 +40,7 @@
        if (helper == null) {
            helper = new NativeNfcWriteHelper(intent, activity);
        }
        helper.setIntent(intent);
        return helper;
    }
@@ -48,9 +52,9 @@
     * @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) {
@@ -122,7 +126,7 @@
    @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) {
@@ -169,8 +173,6 @@
                                }
                            }
                        }
                        if (isOpen) {
                            int bIndex = mfc.sectorToBlock(a);
                            //写卡
@@ -225,8 +227,11 @@
                }
            } catch (Exception e) {
                e.printStackTrace();
                callBack.isSusses(false, a + "扇区写卡报错" + e.getMessage());
                return false;
            }
        } else {
            callBack.isSusses(false, a + "扇区写卡报错,byte数组大小不为16");
        }
        return false;
    }