Search code examples
androidnfcndefandroid-applicationrecord

NFC tag size for launching application


New to the NFC concept, was wondering what size of tag I need (48, 144 or 454 bytes) for the "Launch application" tag option where you simply enter an app package to launch.

Say my package name is standard sized: xxx.xxxxxxxxxxxx.xxxxx


Solution

  • For an Android Application Record (AAR) you will need the following amount of memory:

    • NDEF Header byte: 1 byte
    • NDEF type length field: 1 byte
    • NDEF payload length field: 1-4 bytes (typically 1 byte for this type of record)
    • NDEF type name "android.com:pkg" (external type): 15 bytes
    • AAR payload: length of package name in bytes when UTF-8 encoded. For your example of xxx.xxxxxxxxxxxx.xxxxx, this makes 22 bytes.

    So the NDEF message (consisting only of the AAR) has 40 bytes (or possibly 43 bytes when using a 4 byte payload length field).

    Once you know the size of your NDEF message, the rest depends on the tag type that you use. For instance, with an NFC Forum Type 2 tag (e.g. MIFARE Ultralight and NTAG), you have at least two more bytes of overhead:

    • NDEF TLV tag field: 1 byte
    • NDEF TLV length field: 1 byte

    Moreover, many Type 2 tags contain a Memory Control TLV and/or a Lock Control TLV block (5 bytes each) within the user memory area.

    Also note that some vendors refer to the overall tag size (which includes memory areas with tag meta data that cannot be used for actual NDEF data) instead of the available user memory.