How to programmatically detect the memory size/page number of an NFC chip

android disable nfc programmatically
advanced nfc commands
android nfc read/write sample code
nfc tag writer android source code
nfc tags
nfc tag reader code
nfc programming

What is the easiest way to programmatically detect the memory size or page count of an NFC chip (MIFARE Ultralight or NTAGxxx) other than probing for specific page numbers and checking if they exist?

Is there a specific byte in the ATR returned or somewhere stored in the protected zone of the chip's memory that tells whether it's a specific NTAGxxx chip, or the page count or the byte count?

NFC basics, However, there are cases when the tag dispatch system cannot determine the type of data based on the first NDEF record. This happens when  Process. When a Type 2 NFC chip is NDEF formatted, special data is written to the NFC chip’s Capability Container. These bytes start with 0xE1 0x10. The Capability Container memory is OTP, meaning that it can only be written to once. This is implemented via a bitwise OR operation.

I think, from the accepted answer the below code make sense,

int numberOfPages = 0;
int tagType = ulTag.getType();
if(tagType == MifareUltralight.TYPE_ULTRALIGHT) {
    numberOfPages = 16;
} else if(tagType == MifareUltralight.TYPE_ULTRALIGHT_C) {
    numberOfPages = 47;

The getMaxTransceiveLength() is to retrieve the maximum amount of bytes that can be sent with transceive(byte[]). Transceive command use first 3 bytes for Flags, Command and Page number respectively.

We need to check the below code working or not ?

int totalBytes = ulTag.getMaxTransceiveLength() + 3;
int totalPages =  totalBytes / ulTag.PAGE_SIZE;

Near field communication overview, This document describes how Android handles discovered NFC tags and how it notifies applications of data that is relevant to the application. It  To find out the part number of each memory module, use these steps: Open Start . Type Command Prompt , right-click the top result and select the Run as administrator option.

for MIFARE ULTRALIGHT you can check version in this way.

public static final int OFFSET_128_BYTE =  0x025;
public static final int OFFSET_48_BYTE  =  0x010;

public static int checkType(MifareUltralight mrfid){
    int cfgOffset = -1;
    byte[] response = null;
    byte[] writeResponse = null;
    try {
        response = mrfid.transceive(new byte[]{
                (byte) 0x60 // GET_VERSION
    } catch (TagLostException tle) {
        Utility.log("setPasswordAndEnable GET_VERSION, TagLostException ... ");
        return cfgOffset;
    } catch (IOException ioe) {
        Utility.log("setPasswordAndEnable GET_VERSION, IOException ... ");
        return cfgOffset;
    if ((response != null) && (response.length >= 8)) {
        // success
        if ((response[0] == (byte) 0x00) && (response[1] == (byte) 0x04)) {
            // tag is from NXP
            if (response[2] == (byte) 0x03) {
                // MIFARE Ultralight
                if ((response[4] == (byte) 0x01) && (response[5] == (byte) 0x00)) {
                    // MIFARE Ultralight EV1 (V0)
                    switch (response[6]) {
                        case (byte) 0x0B:
                            // MF0UL11
                            cfgOffset = OFFSET_48_BYTE;
                        case (byte) 0x0E:
                            // MF0UL21
                            cfgOffset = OFFSET_128_BYTE;

                            // unknown
    return cfgOffset;

Mifare - St4k, 3. answers. 1,014. views. How to programmatically detect the memory size/page number of an NFC chip. tagsnfcrfidmifarefingerprinting. Feb 20 '15 3:01. Auras. So you will have only card emulation working. but in case of screen off, you have the main CPU running. So you can access it from NFC Chip and make NFC work even tag read/write,P2P along with card emulation. This can be achieved only if changes are made in NFC Chip firmware and also in the kernel of main CPU – Vivek K N Oct 3 '15 at 17:16

NFC Tags, NDEF and Android (with Kotlin) –, Step-by-step walkthrough: add NFC to your Android app with Kotlin. for many years, this was the final missing piece to bring NFC tag scenarios to the masses. on various factors: features (encryption), memory size, speed and cost. Place a link to the app store on that web page to “upgrade” the user. This discrepancy can be understood as follows. Wmic command shows the total installed memory on the system where as systeminfo command shows usable memory (which is total mermory – hardware reserved memory). For more information, check this out 10 comments… add one. lenora.

Core NFC, Detect NFC tags, read messages that contain NDEF data, and save data to writable tags. On This Page Using Core NFC, you can read Near Field Communication (NFC) tags of types 1 Name: Privacy - NFC Scan Usage Description  How NFC tags are dispatched to applications. When the tag dispatch system is done creating an intent that encapsulates the NFC tag and its identifying information, it sends the intent to an interested application that filters for the intent.

NFC Tags Specs, Compare different NFC Chips to better understand which one to choose between NTAG®, Available memory (2), 144 bytes, 504 bytes, 888 bytes For the high number of read/write cycles supported; for the long-term data retention; for the  Now we have the page size of 4KB i.e.2^12 bytes.Thus the number of pages in program are 2^20.(no. of pages in program = program size/page size).Now the size of page table entry is 4 byte hence the size of page table is 2^20*4 = 4MB(size of page table = no. of pages in program * page table entry size).