cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot have access to writable memory or it's size (Android App). error :TAG_CMD_CALLED_FROM_UI_THREAD

Eraqu
Associate

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

1 ACCEPTED SOLUTION

Accepted Solutions
Damien G.
ST Employee

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

View solution in original post

2 REPLIES 2
Eraqu
Associate

Precision:

Error is "TAG_CMD_CALLED_FROM_UI_THREAD"

Damien G.
ST Employee

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