androidnfcuniqueidentifierhcenfc-p2p

How can I read the NFC ID of another Android device?


I want to exchange (or only read) the NFC tag ID from one Android device to another but I don't know if I should use peer-to-peer mode or emulate an NFC tag with HCE.

If I use HCE, is the emulated tag ID unique?

What is the better option or is there a simpler one?


Solution

  • Neither P2P nor HCE will provide you a unique ID, least not on any phone I'm aware of. With P2P it's required that the ID exchanged in ATR is random. With HCE the emulated tag ID is usually set to 08h plus a random number. There may be API call to set but I'm not aware of such. But it makes a lot of sense that a phone can not be uniquely identified by just anyone reading.