Mifare Classic & Ultralight Extension

I think I solved.
Attached my extension,
the source of the extension,
and an app inventor project for test.
At this moment the extension provide some information of a Mifare Classic Tag:

  • Uid
  • Type
  • Size
  • Number of Sectors
  • Number of Blocks

It should works also with Mifare Ultralight (but I don't have this kind of Tag to try)
To test the .aia you have to create and install the .apk
and the NFC in your smartphone must be enable

Who interested about this extension try it, and feel free to modify.
mifare.info.aix (12.7 KB)
MifareInfo.txt (9.7 KB)
MifareInfo.aia (14.6 KB)

Best Regards


Nice Extension @Marco_Perrone

I saw only two people who made an extension for NFC, so Congratulations @Marco_Perrone :star_struck: :kissing_heart:

And @Taifun please take a look at this. Thank you :pray: :grin:

Thank You very much Salman


thank you for your contribution...
please edit your post and add a little bit of documentation...
which properties, methods and events are available? how to use it?
thank you
added in the extensions directory... https://puravidaapps.com/extensions.php


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

This is the new version of my MifareInfo extension.
In this version I have added some feautures:

  • Authentication with Key A
  • Read Block
  • Write Block
    The extension have some events and property and functions here a small explanation.
    The following events work when You approach a Mifare Tag to your smartphone with the app opened:
    Provide the Mifare Tag Uid
    Provide the Mifare Tag Type
    Provide the Mifare Tag bytes size
    Provide the Mifare Tag number of sectors
    Provide the Mifare Tag number of blocks

Provide all the info data of the last Mifare Tag approached

True to read a block, false to write a block

Provide the Key A necessary for the Mifare Classic Authentication after this it is possible Read or Write a block if the Key is correct and has the permission to do it.
The default Key A is FFFFFFFFFFFF
The Mifare Tag must be near the Android device

Read the Block specified (after the authentication) with a number between 0 and the number of blocks minus 1
The Mifare Tag must be near the Android device
The extension calculate the Sector to authenticate


Write the Block specified (after the authentication) with a number between 1 and the number of blocks minus 1.
The Mifare Tag must be near the Android device.
The extension calculate the Sector to authenticate
The data to be written must not be greater than 16 bytes, HEX format.
If You write less than 16 bytes the extension add 0 tho the remain bytes

N.B. Not all the blocks are equal in a Mifare Tag, every sector has blocks for user data and a block called sector trailer, here are stored the authentication key and the access bits. So You must pay attention to write data in the correct block or your Mifare Tag could become unavailable. Before to start write data is good to read this document to understand how Mifare Tag works https://www.nxp.com/docs/en/data-sheet/MF1S50YYX_V1.pdf

Here my latest files:
mifare.info.aix (15.9 KB) Extension
MifareInfo.txt (15.0 KB) Source file
MifareInfo.aia (27.7 KB) Project test

N.B. After You install the .apk the first time You approach a Mifare Tag to your device a pop-up wil ask You if You want to use the default NTAG Info app or our MifareInfo (or your project) , You must select MifareInfo (or your project) otherwise when You approach a Mifare Tag the intent will not go to our app


Here the new extension with Mifare Ultralight support

1 Like

Hi everybody,
I improved my extension and I added the support for Mifare Ultralight technology, it is different from Mifare Classic (obviously). There are 3 differents types of ultralight tags:

  • Ultralight (no authentication)
  • Ultralight C (3DES authentication)
  • Ultralight EV1 (32-bit password + password acknowledge)

The memory is divided into pages and each page is 4 bytes, in the memory there are some special bytes for the uid, for the password and so on, and obviously the bytes for the user.
For more information:

With this new extensions I added some functions and updated of old ones.

Get the UID of Mifare Classic and Mifare Ultralight

Get the Type of Mifare Classic and Mifare Ultralight

Offset number of the page to read.

Page contains the 4 pages read starting from the offset specified in the previous property

Write a page in a Mifare Ultralight Tag
Page: the page number of the tag
DataToWrite: the data (4bytes)

If Your tag is not protected You can use the functions above as are.
Instead if your tag is protected or You want to enable the authentication I developed the functions for Mifare Ultralight EV1 (for now)

Write the password (4bytes) and the pack (2bytes) in the special pages of the tag.
How does it work? When You try to authenticate if the password is correct the tag reply with the pack and if the pack has the value that You expect means that the tag is correct (the extension do the check for You)

After You wrote the Password and the Pack, You can enable the Protection starting from the page number.
Enable: true or false (enable or disable the protection)
PageNumber: usally 4 because is the first page for user data

The Password value to use when the tag is protected

The Pack value to use when the tag is protected

Obviously when the protection is enable You need to authenticate before to change the password, pack or disable the protection.

Here my latest files:
mifare.info.aix (21.8 KB) Extensions
MifareInfo.txt (30.0 KB) Source code
MifareInfo.aia (38.3 KB) Project test

Best Regards


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

Hi Marco, thank you for your contribution... somehow I missed your extension update... let me suggest you to follow the naming conventions and update your extension accordingly,,, thank you...


Did you tested with chinese uhf tag readers long range?

Hi @Benoit_De_Guffroy,
no I did not try, but i think it cannot work(but this is my opinion) fort two reason

  1. Mifare works on 13,56 Mhz UHF works (for my little experience) on 433 Mhz and above.
  2. I suppose that UHF Tag need specific command to read and write memory. For example in Mifare Classic and Mifare Ultralight the memory is structured completely different.
    Best Regards

@Marco_Perrone I have downloaded your aia version from the post written on May 21. After building it and loading the APK it doesnt want to install with a message "App not installed as package appears to be invalid". I have tried a few versions and I have tried resetting the phone. Other builds work. Could it be that some permissions in the new SDK or something else changed in the meantime?

Hi @duv, I have the same project installed in my smartphone and works without problem.
I just compiled and tried again on my smartphone without problem (it always the same project)
Sorry I am not authorized to upload APK.
Maybe a problem with the Android version? My Android is 10.
Best Regards

Hi @Marco_Perrone Thanks for the quick replay and for testing. It seems that it is an android version problem. I am running 13 and according to the internet this is a likely problem. It seems like some permissions are missing in the APK file but I dont know anything about android programming to figure out what needs to be changed

Hi @Marco_Perrone, your extension is excellent, we use it for a lot of phone authentication but it doesn't seem to work with phones on Android 12 and up. I have tried everything recommended by AI2 Stuff (for example: android:exported="true" to the Manifest) and I can't install APK to the phone and can't upload AAB to the Google Play store. Do you plan on fixing this issue to work with Android 12 and up?

Thank You @Leppke,
the main problem is I don't have an Android 12 device at this moment so I cannot reply the issue.
I cannot tell You when, but when I will have an Android 12 or 13 device I will check.
Sorry I understand that this is not the answer that You want, but I will try to solve in the next future.
Best Regards

Hi @Leppke,
Do You have the same problem with my Project Test? This is to understand if the problem is related to my extension or something else in your app that I don't know.
Thank You

Hi @Marco_Perrone,
Thank you for your reply. We only use the getuid block of your extension and if I try without it, it works. When I try to upload the AAB Bundle with your extension to the Google Play Console, I get an error message which directs me to this website to fix the issue: Behavior changes: Apps targeting Android 12  |  Android Developers. You could try testing your extension on the Google Play Console or try an Android 12+ emulator.
Thank you