Skip to content

Instantly share code, notes, and snippets.

@pjwelcome
Created September 3, 2017 07:58
Show Gist options
  • Save pjwelcome/1aed3dd849d892abf718b6d17287d6fe to your computer and use it in GitHub Desktop.
Save pjwelcome/1aed3dd849d892abf718b6d17287d6fe to your computer and use it in GitHub Desktop.
fun retrieveNFCMessage(intent: Intent?): String {
intent?.let {
if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action) {
val nDefMessages = getNDefMessages(intent)
nDefMessages[0].records?.let {
it.forEach {
it?.payload.let {
it?.let {
return String(it)
}
}
}
}
} else {
return "Touch NFC tag to read data"
}
}
return "Touch NFC tag to read data"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment