# NfcA

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

# NfcA

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/nfc/tech/NfcA "View this page in Kotlin")\|Java

`
public

final

class
NfcA
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)`


`

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

<br />

*** ** * ** ***

Provides access to NFC-A (ISO 14443-3A) properties and I/O operations on a[Tag](https://developer.android.com/reference/android/nfc/Tag).

Acquire a[NfcA](https://developer.android.com/reference/android/nfc/tech/NfcA)object using[get(Tag)](https://developer.android.com/reference/android/nfc/tech/NfcA#get(android.nfc.Tag)).

The primary NFC-A I/O operation is[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[])). Applications must implement their own protocol stack on top of[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[])).

**Note:** Methods that perform I/O operations require the[Manifest.permission.NFC](https://developer.android.com/reference/android/Manifest.permission#NFC)permission.

## Summary

|                                                                                                                                                                           ### Public methods                                                                                                                                                                            ||
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                         | ` `[close](https://developer.android.com/reference/android/nfc/tech/NfcA#close())`() ` Disable I/O operations to the tag from this[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)object, and release resources.                                |
| ` void`                                                                         | ` `[connect](https://developer.android.com/reference/android/nfc/tech/NfcA#connect())`() ` Enable I/O operations to the tag from this[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)object.                                                    |
| ` static `[NfcA](https://developer.android.com/reference/android/nfc/tech/NfcA) | ` `[get](https://developer.android.com/reference/android/nfc/tech/NfcA#get(android.nfc.Tag))`(`[Tag](https://developer.android.com/reference/android/nfc/Tag)` tag) ` Get an instance of[NfcA](https://developer.android.com/reference/android/nfc/tech/NfcA)for the given tag.        |
| ` byte[]`                                                                       | ` `[getAtqa](https://developer.android.com/reference/android/nfc/tech/NfcA#getAtqa())`() ` Return the ATQA/SENS_RES bytes from tag discovery.                                                                                                                                          |
| ` int`                                                                          | ` `[getMaxTransceiveLength](https://developer.android.com/reference/android/nfc/tech/NfcA#getMaxTransceiveLength())`() ` Return the maximum number of bytes that can be sent with[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[])). |
| ` short`                                                                        | ` `[getSak](https://developer.android.com/reference/android/nfc/tech/NfcA#getSak())`() ` Return the SAK/SEL_RES bytes from tag discovery.                                                                                                                                              |
| ` `[Tag](https://developer.android.com/reference/android/nfc/Tag)               | ` `[getTag](https://developer.android.com/reference/android/nfc/tech/NfcA#getTag())`() ` Get the[Tag](https://developer.android.com/reference/android/nfc/Tag)object backing this[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)object.        |
| ` int`                                                                          | ` `[getTimeout](https://developer.android.com/reference/android/nfc/tech/NfcA#getTimeout())`() ` Get the current[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[]))timeout in milliseconds.                                           |
| ` boolean`                                                                      | ` `[isConnected](https://developer.android.com/reference/android/nfc/tech/NfcA#isConnected())`() ` Helper to indicate if I/O operations should be possible.                                                                                                                            |
| ` void`                                                                         | ` `[setTimeout](https://developer.android.com/reference/android/nfc/tech/NfcA#setTimeout(int))`(int timeout) ` Set the[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[]))timeout in milliseconds.                                     |
| ` byte[]`                                                                       | ` `[transceive](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[]))`(byte[] data) ` Send raw NFC-A commands to the tag and receive the response.                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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` `[android.nfc.tech.TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)` ` |----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void`                                                           | ` `[close](https://developer.android.com/reference/android/nfc/tech/TagTechnology#close())`() ` Disable I/O operations to the tag from this[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)object, and release resources.                         | | ` abstract void`                                                           | ` `[connect](https://developer.android.com/reference/android/nfc/tech/TagTechnology#connect())`() ` Enable I/O operations to the tag from this[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)object.                                             | | ` abstract `[Tag](https://developer.android.com/reference/android/nfc/Tag) | ` `[getTag](https://developer.android.com/reference/android/nfc/tech/TagTechnology#getTag())`() ` Get the[Tag](https://developer.android.com/reference/android/nfc/Tag)object backing this[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)object. | | ` abstract boolean`                                                        | ` `[isConnected](https://developer.android.com/reference/android/nfc/tech/TagTechnology#isConnected())`() ` Helper to indicate if I/O operations should be possible.                                                                                                                     | ||
| From interface` `[java.io.Closeable](https://developer.android.com/reference/java/io/Closeable)` ` |------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/io/Closeable#close())`() ` Closes this stream and releases any system resources associated with it. | ||
| From interface` `[java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||

## Public methods

### close

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

```
public void close ()
```

Disable I/O operations to the tag from this[TagTechnology](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[IOException](https://developer.android.com/reference/java/io/IOException).

Requires the[Manifest.permission.NFC](https://developer.android.com/reference/android/Manifest.permission#NFC)permission.

<br />

|                                    Throws                                     ||
|----------------------------------------------------------------------------|---|
| [IOException](https://developer.android.com/reference/java/io/IOException) |   |

### connect

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

```
public void connect ()
```

Enable I/O operations to the tag from this[TagTechnology](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[IOException](https://developer.android.com/reference/java/io/IOException)by calling[close()](https://developer.android.com/reference/android/nfc/tech/TagTechnology#close())from another thread.

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

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

Requires the[Manifest.permission.NFC](https://developer.android.com/reference/android/Manifest.permission#NFC)permission.

<br />

|                                    Throws                                     ||
|----------------------------------------------------------------------------|---|
| [IOException](https://developer.android.com/reference/java/io/IOException) |   |

### get

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

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

Get an instance of[NfcA](https://developer.android.com/reference/android/nfc/tech/NfcA)for the given tag.

Returns null if[NfcA](https://developer.android.com/reference/android/nfc/tech/NfcA)was not enumerated in[Tag.getTechList](https://developer.android.com/reference/android/nfc/Tag#getTechList()). This indicates the tag does not support NFC-A.

Does not cause any RF activity and does not block.

<br />

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

|                                          Returns                                           ||
|-----------------------------------------------------------------------|---------------------|
| [NfcA](https://developer.android.com/reference/android/nfc/tech/NfcA) | NFC-A object <br /> |

### getAtqa

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

```
public byte[] getAtqa ()
```

Return the ATQA/SENS_RES bytes from tag discovery.

Does not cause any RF activity and does not block.

<br />

|               Returns                ||
|----------|----------------------------|
| `byte[]` | ATQA/SENS_RES bytes <br /> |

### getMaxTransceiveLength

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

```
public int getMaxTransceiveLength ()
```

Return the maximum number of bytes that can be sent with[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[])).

<br />

|                                                                               Returns                                                                                ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the maximum number of bytes that can be sent with[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[])). <br /> |

### getSak

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

```
public short getSak ()
```

Return the SAK/SEL_RES bytes from tag discovery.

Does not cause any RF activity and does not block.

<br />

|          Returns          ||
|---------|------------------|
| `short` | SAK bytes <br /> |

### getTag

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

```
public Tag getTag ()
```

Get the[Tag](https://developer.android.com/reference/android/nfc/Tag)object backing this[TagTechnology](https://developer.android.com/reference/android/nfc/tech/TagTechnology)object.

<br />

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

### getTimeout

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

```
public int getTimeout ()
```

Get the current[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[]))timeout in milliseconds.

Requires the[Manifest.permission.NFC](https://developer.android.com/reference/android/Manifest.permission#NFC)permission.

<br />

|                   Returns                   ||
|-------|--------------------------------------|
| `int` | timeout value in milliseconds <br /> |

|                                                                         Throws                                                                         ||
|------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [SecurityException](https://developer.android.com/reference/java/lang/SecurityException) | if the tag object is reused after the tag has left the field |

### isConnected

Added in[API level 10](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[connect()](https://developer.android.com/reference/android/nfc/tech/TagTechnology#connect())has completed, and[close()](https://developer.android.com/reference/android/nfc/tech/TagTechnology#close())has not been called, and the[Tag](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 /> |

### setTimeout

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

```
public void setTimeout (int timeout)
```

Set the[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[]))timeout in milliseconds.

The timeout only applies to[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[]))on this object, and is reset to a default value when[close()](https://developer.android.com/reference/android/nfc/tech/NfcA#close())is called.

Setting a longer timeout may be useful when performing transactions that require a long processing time on the tag such as key generation.

Requires the[Manifest.permission.NFC](https://developer.android.com/reference/android/Manifest.permission#NFC)permission.

<br />

|                       Parameters                       ||
|-----------|---------------------------------------------|
| `timeout` | `int`: timeout value in milliseconds <br /> |

|                                                                         Throws                                                                         ||
|------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [SecurityException](https://developer.android.com/reference/java/lang/SecurityException) | if the tag object is reused after the tag has left the field |

### transceive

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

```
public byte[] transceive (byte[] data)
```

Send raw NFC-A commands to the tag and receive the response.

Applications must not append the EoD (CRC) to the payload, it will be automatically calculated.

Applications must only send commands that are complete bytes, for example a SENS_REQ is not possible (these are used to manage tag polling and initialization).

Use[getMaxTransceiveLength()](https://developer.android.com/reference/android/nfc/tech/NfcA#getMaxTransceiveLength())to retrieve the maximum number of bytes that can be sent with[transceive(byte)](https://developer.android.com/reference/android/nfc/tech/NfcA#transceive(byte[])).

This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with[IOException](https://developer.android.com/reference/java/io/IOException)if[close()](https://developer.android.com/reference/android/nfc/tech/NfcA#close())is called from another thread.

Requires the[Manifest.permission.NFC](https://developer.android.com/reference/android/Manifest.permission#NFC)permission.

<br />

|              Parameters              ||
|--------|------------------------------|
| `data` | `byte`: bytes to send <br /> |

|                   Returns                   ||
|----------|-----------------------------------|
| `byte[]` | bytes received in response <br /> |

|                                                                Throws                                                                 ||
|----------------------------------------------------------------------------|-----------------------------------------------------------|
|                                                                            | if the tag leaves the field                               |
| [IOException](https://developer.android.com/reference/java/io/IOException) | if there is an I/O failure, or this operation is canceled |