Search code examples
androidnfc

Writing multiple data types in NFC tags in a single tap


Is it possible to write more than one data type (like two urls or one url and one text) into a NFC tag from Android in a single tap?


Solution

  • You can, but when you scan a tag, it can only have one data type that Android uses to determine what type of tag it is. This data type is determined by the first NDEF record in your NDEF message. Android assigns a MIME type or URI to this record so it can figure out which application is best to start to handle the tag. So, if you write a text record and URI on a tag, Android will think it is a plain text tag if that record is first, or a URI tag if that record is first. You can still read all the data as normal though.