Код: Выделить всё
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
< /code>
и < /p>
nfcAdapter = NfcAdapter.getDefaultAdapter(this)
+ private fun handleIntent(intent: Intent) {
+ val action = intent.action
+ Log.d(TAG, "Intent action: $action")
+
+ if (NfcAdapter.ACTION_NDEF_DISCOVERED == action ||
+ NfcAdapter.ACTION_TECH_DISCOVERED == action ||
+ NfcAdapter.ACTION_TAG_DISCOVERED == action) {
...
+ private fun processTag(tag: Tag) {
+ Log.d(TAG, "Processing NFC tag")
+ runOnUiThread {
+ statusText.text = "NFC Tag Detected!"
+ }
+
+ val sb = StringBuilder()
+ sb.append("Tag ID: ${bytesToHex(tag.id)}\n")
+ sb.append("Tech List: ${tag.techList.joinToString(", ")}\n\n")
+
+ val ndef = Ndef.get(tag)
+ if (ndef != null) {
+ try {
+ ndef.connect()
+ val ndefMessage = ndef.ndefMessage
Подробнее здесь: https://stackoverflow.com/questions/796 ... on-android