Read data from MIFARE tag


the App Inventor is completely new to me. I have achieved to run my app and I am quite experienced with coding. But I run into problems when trying to read from a NFC tag. So I hope to find help on this forum.

I am trying to read Data from a MIFARE classic 1k tag. I have found the extension Mifare Classic & Ultralight Extension from user @Marco_Perrone. I'm not quite sure if it helps with my problem.

What I want to do:

  • I have tags from a different application.
  • I want to read the data written on the tags.
  • I want my code to act depending on this data. Mainly display the data on the screen with a colorcode.
  • As far as I can see, the relevant data is stored in sector 04.

Can anybody provide me some advice?


Welcome Horst.

What the community knows about MIFARE tag may be helpful.

You might contact the manufacturer NFC tags | MIFARE

Hi @HorstKevin,
yes with my extension You can read the data wrote in the Mifare classic tag.
Did You try the sample?
You say that the data is stored in sector 04, attention a sector is a group of blocks, so with my extension you have to read one by one the blocks of sector 04.
The blocks to read should be 16, 17, 18.
Read this document to understand how the mifare classic memory is mapped

Best Regards

Thank you @Marco_Perrone!

I have read through the document, thank you for the link.
And I have tried to install your example. But the installation exited because of an invalid package (?).
Anyway, I have tried to mimic your code to read the data from a given block and display it on a label but didn't achieve any progress so far.

Could anybody provide me a hint for the following:

  • I have a textbox tb_BlockNumber and a label lb_Output.
  • Whenever a tag is placed on the sensor, the data from block tb_BlockNumber should be displayed in lb_Output.

I suppose You have an invalid package becuse you use the old extension.
Update the aia sample with this extension and try to create the apk to install in your smartphone


About your request, You can use GetUid so when a tag is place on the sensor the event is fired and You can do what You want

Ciao Marco

Thank you, that does everything I want it to do :smile:

You are welcome

Now that "MyApp" can read and handle data from a tag, I have the following problem:

Whenever a tag is close to my phone, MyApp opens and executes. This happens to any tag so I can't use other NFC-apps while MyApp is installed.

Is it possible to somehow turn off this behaviour? I.e. if MyApp is running, then read the tag and do whatever the blocks say. If MyApp is closed, then don't start if a tag is detected.

@Marco_Perrone: Do you have an idea how to prevent the app from starting when a tag is held on the phone, even when the app is closed?

Hi @HorstKevin ,
I think not because the extension use:
android.nfc.action.TAG_DISCOVERED to "read" the tag so when You approach the tag immediately the app start his job, for your purpose the extension should use
android.nfc.action.TECH_DISCOVERED and use foreground dispatch as I wrote here (I suppose):

but I was not able to develop these functions, so at this moment You can use App Inventori and Mifare tag as You can see

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.