Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/nfc/tech/NfcBarcode#constants) \| [Methods](https://developer.android.com/reference/android/nfc/tech/NfcBarcode#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/nfc/tech/NfcBarcode#inhmethods)

# NfcBarcode

*** ** * ** ***

` public final class NfcBarcode `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/android/nfc/tech/TagTechnology `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.nfc.tech.NfcBarcode |

<br />

*** ** * ** ***

Provides access to tags containing just a barcode.

Acquire an `https://developer.android.com/reference/android/nfc/tech/NfcBarcode` object using `https://developer.android.com/reference/android/nfc/tech/NfcBarcode#get(android.nfc.Tag)`.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/nfc/tech/NfcBarcode#TYPE_KOVIO` Kovio Tags |
| `int` | `https://developer.android.com/reference/android/nfc/tech/NfcBarcode#TYPE_UNKNOWN` <br /> |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/nfc/tech/NfcBarcode#close()() ` Disable I/O operations to the tag from this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object, and release resources. |
| ` void` | ` https://developer.android.com/reference/android/nfc/tech/NfcBarcode#connect()() ` Enable I/O operations to the tag from this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object. |
| ` static https://developer.android.com/reference/android/nfc/tech/NfcBarcode` | ` https://developer.android.com/reference/android/nfc/tech/NfcBarcode#get(android.nfc.Tag)(https://developer.android.com/reference/android/nfc/Tag tag) ` Get an instance of `https://developer.android.com/reference/android/nfc/tech/NfcBarcode` for the given tag. |
| ` byte[]` | ` https://developer.android.com/reference/android/nfc/tech/NfcBarcode#getBarcode()() ` Returns the barcode of an NfcBarcode tag. |
| ` https://developer.android.com/reference/android/nfc/Tag` | ` https://developer.android.com/reference/android/nfc/tech/NfcBarcode#getTag()() ` Get the `https://developer.android.com/reference/android/nfc/Tag` object backing this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object. |
| ` int` | ` https://developer.android.com/reference/android/nfc/tech/NfcBarcode#getType()() ` Returns the NFC Barcode tag type. |
| ` boolean` | ` https://developer.android.com/reference/android/nfc/tech/NfcBarcode#isConnected()() ` Helper to indicate if I/O operations should be possible. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/nfc/tech/TagTechnology ` ` abstract void` ` https://developer.android.com/reference/android/nfc/tech/TagTechnology#close()() `

Disable I/O operations to the tag from this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object, and release resources.
` abstract void` ` https://developer.android.com/reference/android/nfc/tech/TagTechnology#connect()() `

Enable I/O operations to the tag from this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object.
` abstract https://developer.android.com/reference/android/nfc/Tag` ` https://developer.android.com/reference/android/nfc/tech/TagTechnology#getTag()() `

Get the `https://developer.android.com/reference/android/nfc/Tag` object backing this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object.
` abstract boolean` ` https://developer.android.com/reference/android/nfc/tech/TagTechnology#isConnected()() `

Helper to indicate if I/O operations should be possible.
From interface ` https://developer.android.com/reference/java/io/Closeable ` ` abstract void` ` https://developer.android.com/reference/java/io/Closeable#close()() `

Closes this stream and releases any system resources associated with it.
From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` ` abstract void` ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() `

Closes this resource, relinquishing any underlying resources.

## Constants

### TYPE_KOVIO

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_KOVIO
```

Kovio Tags

<br />

Constant Value: 1 (0x00000001)

### TYPE_UNKNOWN

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TYPE_UNKNOWN
```

<br />

<br />

Constant Value: -1 (0xffffffff)

## Public methods

### close

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void close ()
```

Disable I/O operations to the tag from this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object, and release resources.

Also causes all blocked I/O operations on other thread to be canceled and return with `https://developer.android.com/reference/java/io/IOException`.

Requires the `https://developer.android.com/reference/android/Manifest.permission#NFC` permission.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### connect

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void connect ()
```

Enable I/O operations to the tag from this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object.

May cause RF activity and may block. Must not be called from the main application thread. A blocked call will be canceled with `https://developer.android.com/reference/java/io/IOException` by calling `https://developer.android.com/reference/android/nfc/tech/TagTechnology#close()` from another thread.

Only one `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object can be connected to a `https://developer.android.com/reference/android/nfc/Tag` at a time.

Applications must call `https://developer.android.com/reference/android/nfc/tech/TagTechnology#close()` when I/O operations are complete.

Requires the `https://developer.android.com/reference/android/Manifest.permission#NFC` permission.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### get

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static NfcBarcode get (Tag tag)
```

Get an instance of `https://developer.android.com/reference/android/nfc/tech/NfcBarcode` for the given tag.

Returns null if `https://developer.android.com/reference/android/nfc/tech/NfcBarcode` was not enumerated in `https://developer.android.com/reference/android/nfc/Tag#getTechList()`.

Does not cause any RF activity and does not block.

<br />

| Parameters ||
|---|---|
| `tag` | `Tag`: an NfcBarcode compatible tag <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/nfc/tech/NfcBarcode` | NfcBarcode object <br /> |

### getBarcode

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] getBarcode ()
```

Returns the barcode of an NfcBarcode tag.

Tags of `https://developer.android.com/reference/android/nfc/tech/NfcBarcode#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:
- 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).
- 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.
- The last 2 bytes comprise the CRC.

Does not cause any RF activity and does not block.

<br />

| Returns ||
|---|---|
| `byte[]` | a byte array containing the barcode <br /> |

**See also:**

- [Thinfilm NFC Barcode tag specification (previously Kovio NFC Barcode)](http://www.thinfilm.no/docs/thinfilm-nfc-barcode-datasheet.pdf)
- [Thinfilm NFC Barcode data format (previously Kovio NFC Barcode)](http://www.thinfilm.no/docs/thinfilm-nfc-barcode-data-format.pdf)

### getTag

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Tag getTag ()
```

Get the `https://developer.android.com/reference/android/nfc/Tag` object backing this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/nfc/Tag` | the `https://developer.android.com/reference/android/nfc/Tag` backing this `https://developer.android.com/reference/android/nfc/tech/TagTechnology` object. <br /> |

### getType

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getType ()
```

Returns the NFC Barcode tag type.

Currently only one of `https://developer.android.com/reference/android/nfc/tech/NfcBarcode#TYPE_KOVIO` or `https://developer.android.com/reference/android/nfc/tech/NfcBarcode#TYPE_UNKNOWN`.

Does not cause any RF activity and does not block.

<br />

| Returns ||
|---|---|
| `int` | the NFC Barcode tag type <br /> |

### isConnected

Added in [API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isConnected ()
```

Helper to indicate if I/O operations should be possible.

Returns true if `https://developer.android.com/reference/android/nfc/tech/TagTechnology#connect()` has completed, and `https://developer.android.com/reference/android/nfc/tech/TagTechnology#close()` has not been called, and the `https://developer.android.com/reference/android/nfc/Tag` is not known to be out of range.

Does not cause RF activity, and does not block.

<br />

| Returns ||
|---|---|
| `boolean` | true if I/O operations should be possible <br /> |