2019-07-17 09:17 AM
I'm working on an android app and using your SDK (using version 1.5.1).
The app can read the Tag name and UID, however, I have not been able to make it read the memory size or the content of the NDEF message.
String tagName = mNfcTag.getName();
TextView tagNameTextView = (TextView) findViewById(R.id.tagNameTextView);
tagNameTextView.setText(tagName);
String uidString = mNfcTag.getUidString();
TextView uidTextView = (TextView) findViewById(R.id.uidTextView);
uidTextView.setText(uidString);
mTagSize = ": " + String.valueOf(mNfcTag.getMemSizeInBytes()) + " bytes";
TextView tagMemSizeTextView = (TextView) findViewById(R.id.tagMemSizeTextView);
tagMemSizeTextView.setText(String.valueOf(mTagSize));
NDEFMsg ndefContent=nfcTag.readNdefMessage();
String contenu=ndefContent.toString();
TextView ndefTextView=(TextView) findViewById(R.id.ndefScanTextView);
ndefTextView.setText(contenu);
mNfcTag.getMemSizeInBytes() on line 9 and nfcTag.readNdefMessage() on line 14 both create an error while mNfcTag.getName() and mNfcTag.getUidString(); both work perfectly.
What is required in order for those commands to work, that I possibly missed/didn't think of?
Regards,
Edwin
Solved! Go to Solution.
2019-07-18 08:58 AM
Hello Edwin,
the error that you report indicates that the command sent to the tag is launched from the Android's UI thread.
The Android reader interface implementation forbids this because it makes the UI unresponsive until the tag sends the response back.
The Android Demo App documentation located in folder integration\android\documentation of the ST25SDK explains all this and recommends that you use an AsyncTask to do the job.
You will also find there an example of a Ndef Write command.
I am attaching the guide to this message for your convenience.
Regards,
Damien
2019-07-18 06:20 AM
Precision:
Error is "TAG_CMD_CALLED_FROM_UI_THREAD"
2019-07-18 08:58 AM
Hello Edwin,
the error that you report indicates that the command sent to the tag is launched from the Android's UI thread.
The Android reader interface implementation forbids this because it makes the UI unresponsive until the tag sends the response back.
The Android Demo App documentation located in folder integration\android\documentation of the ST25SDK explains all this and recommends that you use an AsyncTask to do the job.
You will also find there an example of a Ndef Write command.
I am attaching the guide to this message for your convenience.
Regards,
Damien