Created
July 26, 2017 19:38
-
-
Save pjwelcome/e92456327a9174c958b5f54980bc9fc8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun createNFCMessage(payload: String, intent: Intent?) : Boolean { | |
val pathPrefix = "peterjohnwelcome.com:nfcapp" | |
val nfcRecord = NdefRecord(NdefRecord.TNF_EXTERNAL_TYPE, pathPrefix.toByteArray(), ByteArray(0), payload.toByteArray()) | |
val nfcMessage = NdefMessage(arrayOf(nfcRecord)) | |
intent?.let { | |
val tag = it.getParcelableExtra<Tag>(NfcAdapter.EXTRA_TAG) | |
return writeMessageToTag(nfcMessage, tag) | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment