Last active
April 7, 2020 10:34
-
-
Save loisenjoki/d087af0ad98a94fce076 to your computer and use it in GitHub Desktop.
Read NFC Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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