private void storeCardInfo(String key) {
    if (key == null || key.length() != 16) {
      Toast.makeText(getContext(), "Length of key must be 16", Toast.LENGTH_SHORT).show();
      throw new IllegalArgumentException("Length of key must be 16");
    }
    Intent intent = new Intent(CardService.INIT_CARD_INTENT);
    int keyLen = 16;
    int lcLen = 1;
    String roomKey = key;
    CardInfo cardInfo = new CardInfo("101", "20160101");
    byte[] createCommand = MessageUtil.hexStringToByteArray("00E00102");
    byte[] cardData = cardInfo.toBytes();
    byte[] storeDataCommand =
        new byte[createCommand.length + lcLen + keyLen + CardInfo.FILE_LENGTH];

    int posKey = createCommand.length + lcLen;
    int posCard = posKey + keyLen;
    int lc = keyLen + CardInfo.FILE_LENGTH;
    System.arraycopy(createCommand, 0, storeDataCommand, 0, createCommand.length);
    System.arraycopy(roomKey.getBytes(), 0, storeDataCommand, posKey, keyLen);
    System.arraycopy(cardData, 0, storeDataCommand, posCard, cardData.length);
    storeDataCommand[createCommand.length] = (byte) lc;
    intent.putExtra(
        CardService.INIT_CARD_MESSAGE, MessageUtil.byteArrayToHexString(storeDataCommand));
    LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
  }
 private void selectApplet() {
   byte[] command = MessageUtil.hexStringToByteArray(SELECT_APPLET);
   Intent intent = new Intent(CardService.INIT_CARD_INTENT);
   intent.putExtra(CardService.INIT_CARD_MESSAGE, MessageUtil.byteArrayToHexString(command));
   LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
 }