Stay organized with collections
Save and categorize content based on your preferences.
NfcBarcode
class NfcBarcode : TagTechnology
Provides access to tags containing just a barcode.
Acquire an NfcBarcode
object using get
.
Summary
Constants |
static Int |
Kovio Tags
|
static Int |
|
Constants
TYPE_KOVIO
static val TYPE_KOVIO: Int
Kovio Tags
Value: 1
TYPE_UNKNOWN
static val TYPE_UNKNOWN: Int
Value: -1
Public methods
close
fun close(): Unit
Exceptions |
java.lang.Exception |
if this resource cannot be closed |
java.io.IOException |
if an I/O error occurs |
java.lang.SecurityException |
if the tag object is reused after the tag has left the field |
connect
fun connect(): Unit
Exceptions |
TagLostException |
if the tag leaves the field |
java.io.IOException |
if there is an I/O failure, or connect is canceled |
java.lang.SecurityException |
if the tag object is reused after the tag has left the field |
get
static fun get(tag: Tag!): NfcBarcode!
Get an instance of NfcBarcode
for the given tag.
Returns null if NfcBarcode
was not enumerated in Tag.getTechList
.
Does not cause any RF activity and does not block.
Parameters |
tag |
Tag!: an NfcBarcode compatible tag |
getBarcode
fun getBarcode(): ByteArray!
Returns the barcode of an NfcBarcode tag.
Tags of TYPE_KOVIO
return 16 bytes:
The first byte is 0x80 ORd with a manufacturer ID, corresponding to ISO/IEC 7816-6.
The second byte describes the payload data format. Defined data format types include the following:
- 0x00: Reserved for manufacturer assignment
- 0x01: 96-bit URL with "http://www." prefix
- 0x02: 96-bit URL with "https://www." prefix
- 0x03: 96-bit URL with "http://" prefix
- 0x04: 96-bit URL with "https://" prefix
- 0x05: 96-bit GS1 EPC
- 0x06-0xFF: reserved
The following 12 bytes are payload:
The last 2 bytes comprise the CRC.
Does not cause any RF activity and does not block.
Return |
ByteArray! |
a byte array containing the barcode |
getTag
fun getTag(): Tag!
getType
fun getType(): Int
Returns the NFC Barcode tag type.
Currently only one of TYPE_KOVIO
or TYPE_UNKNOWN
.
Does not cause any RF activity and does not block.
Return |
Int |
the NFC Barcode tag type |
isConnected
fun isConnected(): Boolean
Return |
Boolean |
true if I/O operations should be possible |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# NfcBarcode\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nNfcBarcode\n==========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/nfc/tech/NfcBarcode \"View this page in Java\") \n\n```\nclass NfcBarcode : TagTechnology\n```\n\n|---|----------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.nfc.tech.NfcBarcode](#) |\n\nProvides access to tags containing just a barcode.\n\nAcquire an [NfcBarcode](#) object using [get](#get(android.nfc.Tag)).\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|-------------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [TYPE_KOVIO](#TYPE_KOVIO:kotlin.Int) Kovio Tags |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [TYPE_UNKNOWN](#TYPE_UNKNOWN:kotlin.Int) \u003cbr /\u003e |\n\n| Public methods ||\n|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [close](#close())`()` \u003cbr /\u003e |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [connect](#connect())`()` \u003cbr /\u003e |\n| static [NfcBarcode](#)! | [get](#get(android.nfc.Tag))`(`tag:` `[Tag](../Tag.html#)!`)` Get an instance of [NfcBarcode](#) for the given tag. |\n| [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)! | [getBarcode](#getBarcode())`()` Returns the barcode of an NfcBarcode tag. |\n| [Tag](../Tag.html#)! | [getTag](#getTag())`()` \u003cbr /\u003e |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getType](#getType())`()` Returns the NFC Barcode tag type. |\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isConnected](#isConnected())`()` \u003cbr /\u003e |\n\nConstants\n---------\n\n### TYPE_KOVIO\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val TYPE_KOVIO: Int\n```\n\nKovio Tags \n\n Value: 1\n\n### TYPE_UNKNOWN\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val TYPE_UNKNOWN: Int\n``` \n\n Value: -1\n\nPublic methods\n--------------\n\n### close\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun close(): Unit\n```\n\n| Exceptions ||\n|-------------------------------|--------------------------------------------------------------|\n| `java.lang.Exception` | if this resource cannot be closed |\n| `java.io.IOException` | if an I/O error occurs |\n| `java.lang.SecurityException` | if the tag object is reused after the tag has left the field |\n\n### connect\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun connect(): Unit\n```\n\n| Exceptions ||\n|-------------------------------|--------------------------------------------------------------|\n| `TagLostException` | if the tag leaves the field |\n| `java.io.IOException` | if there is an I/O failure, or connect is canceled |\n| `java.lang.SecurityException` | if the tag object is reused after the tag has left the field |\n\n### get\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic fun get(tag: Tag!): NfcBarcode!\n```\n\nGet an instance of [NfcBarcode](#) for the given tag.\n\nReturns null if [NfcBarcode](#) was not enumerated in [Tag.getTechList](../Tag.html#getTechList()).\n\nDoes not cause any RF activity and does not block.\n\n| Parameters ||\n|-------|----------------------------------------------------|\n| `tag` | [Tag](../Tag.html#)!: an NfcBarcode compatible tag |\n\n| Return ||\n|------------------|-------------------|\n| [NfcBarcode](#)! | NfcBarcode object |\n\n### getBarcode\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getBarcode(): ByteArray!\n```\n\nReturns the barcode of an NfcBarcode tag.\n\nTags of [TYPE_KOVIO](#TYPE_KOVIO:kotlin.Int) return 16 bytes:\n\n- The first byte is 0x80 ORd with a manufacturer ID, corresponding to ISO/IEC 7816-6.\n- The second byte describes the payload data format. Defined data format types include the following:\n- 0x00: Reserved for manufacturer assignment\n- 0x01: 96-bit URL with \"http://www.\" prefix\n- 0x02: 96-bit URL with \"https://www.\" prefix\n- 0x03: 96-bit URL with \"http://\" prefix\n- 0x04: 96-bit URL with \"https://\" prefix\n- 0x05: 96-bit GS1 EPC\n- 0x06-0xFF: reserved\n- The following 12 bytes are payload:\n- In case of a URL payload, the payload is encoded in US-ASCII, following the limitations defined in RFC3987. {@see [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt)}\n- In case of GS1 EPC data, see [GS1 Electronic Product Code (EPC) Tag Data Standard (TDS)](http://www.gs1.org/gsmp/kc/epcglobal/tds/) for more details.\n- The last 2 bytes comprise the CRC.\n\nDoes not cause any RF activity and does not block.\n\n| Return ||\n|------------------------------------------------------------------------------------------|-------------------------------------|\n| [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)! | a byte array containing the barcode |\n\n**See Also**\n\n### getTag\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getTag(): Tag!\n```\n\n| Return ||\n|----------------------|----------------------------------------------------------------------------------------------------------------|\n| [Tag](../Tag.html#)! | the [Tag](../Tag.html#) backing this [TagTechnology](/reference/kotlin/android/nfc/tech/TagTechnology) object. |\n\n### getType\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getType(): Int\n```\n\nReturns the NFC Barcode tag type.\n\nCurrently only one of [TYPE_KOVIO](#TYPE_KOVIO:kotlin.Int) or [TYPE_UNKNOWN](#TYPE_UNKNOWN:kotlin.Int).\n\nDoes not cause any RF activity and does not block.\n\n| Return ||\n|----------------------------------------------------------------------------|--------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the NFC Barcode tag type |\n\n### isConnected\n\nAdded in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun isConnected(): Boolean\n```\n\n| Return ||\n|------------------------------------------------------------------------------------|-------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if I/O operations should be possible |"]]