Last active
August 29, 2015 14:11
-
-
Save miguelcardo/39d7e246075dc433d65b to your computer and use it in GitHub Desktop.
Communicate with cardlet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void readCard(final IsoDep card) { | |
byte[] response = null; | |
try { | |
card.connect(); | |
response = card.transceive(Utils.selectApdu(APPLICATION_ID)); | |
card.close(); | |
} catch (IOException e) { | |
Log.e(TAG, "Error reading card", e); | |
} | |
if (response != null && Arrays.equals(Utils.statusBytes(response), successfulApdu)) { | |
byte[] payload = Utils.responseData(response); | |
String printableResponse = new String(); | |
for (int i=0; i<payload.length; i++) printableResponse += (char)payload[i]; | |
mainMessage.setText(printableResponse); | |
} else { | |
// enable the button so the user can install the cardlet | |
mainMessage.setText(R.string.cardlet_not_installed); | |
installButton.setVisibility(View.VISIBLE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment