Skip to content

Instantly share code, notes, and snippets.

@loisenjoki
Last active April 7, 2020 10:34
Show Gist options
  • Save loisenjoki/d087af0ad98a94fce076 to your computer and use it in GitHub Desktop.
Save loisenjoki/d087af0ad98a94fce076 to your computer and use it in GitHub Desktop.
Read NFC Data
private fun readFromNFC(ndef: Ndef) {
try {
ndef.connect()
val ndefMessage = ndef.ndefMessage
val message = String(ndefMessage.records[0].payload)
Log.d(TAG, "readFromNFC: $message")
mTvMessage.text = message
ndef.close()
} catch (e: IOException) {
e.printStackTrace()
} catch (e: FormatException) {
e.printStackTrace()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment