Hello,
We are using the taplinx android SDK and are experiencing an intermittent issue on some of our devices. The following error is being thrown when trying to get the card type from a tag discovered intent:
public class TapLinxHelper {
public static final String TAG = "TapLinx";
// The TapLinX library instance
private NxpNfcLib tapLinxInstance = null;
public boolean IsInitialized = false;
public boolean initializeLibrary(Activity activity, String key, String offlineKey) {
tapLinxInstance = NxpNfcLib.getInstance();
try {
if(offlineKey != null && !offlineKey.isEmpty()) {
tapLinxInstance.registerActivity(activity, key, offlineKey);
}else{
tapLinxInstance.registerActivity(activity, key);
}
} catch (NxpNfcLibException ex) {
Log.d(TAG, "onNewIntent");
return false;
} catch (Exception e) {
// do nothing added to handle the crash if any
return false;
}
IsInitialized = true;
return true;
}
public void onResume() {
if (tapLinxInstance != null) {
tapLinxInstance.startForeGroundDispatch();
}
}
public void onPause() {
if (tapLinxInstance != null) {
tapLinxInstance.stopForeGroundDispatch();
}
}
public CardResult readCard(final Intent intent, int applicationID, int cardKeyNumber, byte[] applicationKey, int fileID) {
CardType cardType = tapLinxInstance.getCardType(intent); // error intermittently thrown at this point
if (cardType != CardType.DESFireEV3) {
throw new IllegalStateException("Unexpected value: " + cardType);
}
Log.d(TAG, "Card type: " + cardType.getTagName());
try {
IDESFireEV3 desFireEV3 = DESFireFactory.getInstance().getDESFireEV3(tapLinxInstance.getCustomModules());
desFireEV3.getReader().connect();
CardResult result = new CardResult();
result.CardType = desFireEV3.getType().getTagName();
result.UID = Utilities.dumpBytes(desFireEV3.getUID());
// generate the key
SecureKeyGenerator keyGenerator = SecureKeyGenerator.getInstance(tapLinxInstance.getCustomModules());
IKeyData key = keyGenerator.getKeyFromKeyBytes(applicationKey, KeyType.AES128);
// select the application
desFireEV3.selectApplication(applicationID);
// authenticate
desFireEV3.authenticate(cardKeyNumber, IDESFireEV1.AuthType.AES, KeyType.AES128, key);
// read data
result.Data = desFireEV3.readData(fileID, 0, 0);
return result;
} catch (Exception e) {
Log.d(TAG, e.getMessage());
}
return null;
}
}
Hello Jimmy,
Thank you for your help, we had followed all the steps described and license string were populated.
I have now modified our implementation so that it ensures the activity is registered before proceeding with a read card, this appears to have fixed the issue.
Thanks again for your help and have a nice day.
Kind Regards,
Hello,
Are you followed all steps described here: https://community.nxp.com/t5/TapLinx-SDK-TagWriter-and/Get-started-with-TapLinx/ta-p/1709890? Do you populate license string before the code you shared?
Also if you can provide full package name (in secure way) so we can check the back end.