| | |
| | | |
| | | import android.content.Intent; |
| | | import android.nfc.NfcAdapter; |
| | | import android.nfc.Tag; |
| | | import android.os.Bundle; |
| | | import android.os.Message; |
| | | import android.view.LayoutInflater; |
| | |
| | | volatile UserCard userCard; |
| | | ActivityRedCardBinding redCardBinding; |
| | | |
| | | Intent intent; |
| | | // Intent intent; |
| | | Tag mTag; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void physicalCardDoing(Tag tag) { |
| | | super.physicalCardDoing(tag); |
| | | mTag = tag; |
| | | ProgressDialog.show(this); |
| | | |
| | | readAllData(tag); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onNewIntent(Intent intent) { |
| | | this.intent = intent; |
| | | ProgressDialog.show(this); |
| | | if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { |
| | | readAllData(intent); |
| | | } |
| | | // this.intent = intent; |
| | | |
| | | super.onNewIntent(intent); |
| | | } |
| | | |
| | |
| | | * 读取全部数据 |
| | | */ |
| | | |
| | | public void readAllData(Intent intent) { |
| | | public void readAllData(Tag intent) { |
| | | NfcReadHelper.getInstence(intent) |
| | | .getOneSectorData(new NfcReadHelper.NFCCallListback() { |
| | | @Override |
| | |
| | | userCard.setBalance(balance); |
| | | userCard.setState("00"); |
| | | |
| | | WriteCardUtils.setUser(intent, userCard); |
| | | WriteCardUtils.setUser(mTag, userCard); |
| | | stateText.append("启用"); |
| | | } else if ("01".equals(state)) { |
| | | userCard.setBalance(balance); |
| | | userCard.setState("01"); |
| | | WriteCardUtils.setUser(intent, userCard); |
| | | WriteCardUtils.setUser(mTag, userCard); |
| | | stateText.append("禁用"); |
| | | } else if ("02".equals(state)) { |
| | | stateText.append("隶属信息不符"); |