Android Question ncf ID defferent between usb reader and B4A

Sofian

Member
I have try code from https://www.b4x.com/android/forum/threads/nfc-reading-and-writing.64451/post-409002
and from USB reader, there different result between USB reader and mobile nfc read with B4A,
USB : 0653603588 , B4A: 0433F526370289 (Techs: [android.nfc.tech.NfcA, android.nfc.tech.MifareUltralight, android.nfc.tech.Ndef])
USB : 2954076006 , B4A: 669F13B0 (Techs: [android.nfc.tech.NfcA, android.nfc.tech.MifareClassic, android.nfc.tech.Ndef])
is there a way to make B4A result same as USB reader ?
 

Attachments

  • WhatsApp Image 2026-10-14 at 19.39.50.jpeg
    WhatsApp Image 2026-10-14 at 19.39.50.jpeg
    237 KB · Views: 22

drgottjr

Expert
Licensed User
Longtime User
from https://developer.android.com/reference/android/nfc/Tag#getId()
public byte[] getId ()
Get the Tag Identifier (if it has one).

The tag identifier is a low level serial number, used for anti-collision and identification.

Most tags have a stable unique identifier (UID), but some tags will generate a random ID every time they are discovered (RID), and there are some tags with no ID at all (the byte array will be zero-sized).

The size and format of an ID is specific to the RF technology used by the tag.

This function retrieves the ID as determined at discovery time, and does not perform any further RF communication or block.
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
B4A returns the bytes (hex) as they are read from memory, and the USB reader already parses the id from them, but they are the same.
At least for these 2 card technologies, the id is the decimal value of the first 4 hex bytes in little-endian format

B4A (leading 4 bytes): 0433F526 (ignore the rest)
Invert byte order (little endian): 26F53304
Convert from hex to dec: 0653603588 (same result as USB reader)

B4A (leading 4 bytes): 669F13B0
Invert byte order (little endian): B0139F66
Convert from hex to dec: 2954076006 (same result as USB reader)

Glad to see you still around here @drgottjr 😀
 
Upvote 0
Top