How to Understand Java API Usage for Felica Cards: Difference between revisions

From wizarPOS
(Created page with "* Get RFCardReaderDevice <syntaxhighlight lang="java" line='line'> device = (RFCardReaderDevice) POSTerminal.getInstance(mContext).getDevice(POSTerminal.DEVICE_NAME_RF_CARD_...")
 
No edit summary
Line 28: Line 28:
   }
   }
</syntaxhighlight>
</syntaxhighlight>
  Felica card is different with a normal contactless CPU card, its' APDU command is special, generally, it includes N(2 bytes,little endian) + CmdID (1 bytes) + data, please refer to the customer spec to get detail information for APDU command.
* Close device
* Close device
<syntaxhighlight lang="java" line='line'>
<syntaxhighlight lang="java" line='line'>
   device.close();
   device.close();
</syntaxhighlight>
</syntaxhighlight>

Revision as of 03:02, 7 April 2021

  • Get RFCardReaderDevice
  device = (RFCardReaderDevice) POSTerminal.getInstance(mContext).getDevice(POSTerminal.DEVICE_NAME_RF_CARD_READER);
  • Open device
  device.open();
  • Search Card
  OperationListener listener = new OperationListener() {
    @Override
    public void handleResult(OperationResult arg0) {
      if (arg0.getResultCode() == OperationResult.SUCCESS) {
        sendSuccessLog2(mContext.getString(R.string.find_card_succeed));
        rfCard = ((RFCardReaderOperationResult) arg0).getCard();
      } else {
        sendFailedLog2(mContext.getString(R.string.find_card_failed));
      }
    }
  };
  device.listenForCardPresent(listener, TimeConstants.FOREVER); The result will be returned in the callback listener.
  • Communicate with Card
  if (rfCard instanceof FelicaCard) {
    result = ((FelicaCard) rfCard).transmit(arryAPDU, 0);
  }
 Felica card is different with a normal contactless CPU card, its' APDU command is special, generally, it includes N(2 bytes,little endian) + CmdID (1 bytes) + data, please refer to the customer spec to get detail information for APDU command.
  • Close device
  device.close();