NfcV

class NfcV : TagTechnology
kotlin.Any
   ↳ android.nfc.tech.NfcV

Provides access to NFC-V (ISO 15693) properties and I/O operations on a Tag.

Acquire a NfcV object using #get.

The primary NFC-V I/O operation is #transceive. Applications must implement their own protocol stack on top of #transceive.

Note: Methods that perform I/O operations require the android.Manifest.permission#NFC permission.
Requires API level 10 (Android 2.3.3, Gingerbread)

Summary

Public methods
ByteArray!

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

Byte

Return the Response Flag bytes from tag discovery.

Tag!

Get the Tag object backing this TagTechnology object.

Byte

Return the DSF ID bytes from tag discovery.

Unit

Enable I/O operations to the tag from this TagTechnology object.

Int

Return the maximum number of bytes that can be sent with #transceive.

Unit

Disable I/O operations to the tag from this TagTechnology object, and release resources.

Boolean

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

static NfcV!
get(tag: Tag!)

Get an instance of NfcV for the given tag.

Public methods

transceive

added in API level 10
fun transceive(data: ByteArray!): ByteArray!

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

Applications must not append the CRC to the payload, it will be automatically calculated. The application does provide FLAGS, CMD and PARAMETER bytes.

Use #getMaxTransceiveLength to retrieve the maximum amount of bytes that can be sent with #transceive.

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 if #close is called from another thread.

Requires the android.Manifest.permission#NFC permission.
Requires API level 10 (Android 2.3.3, Gingerbread)

Parameters
data ByteArray!: bytes to send
Return
ByteArray!: bytes received in response
Exceptions
TagLostException if the tag leaves the field
IOException if there is an I/O failure, or this operation is canceled

getResponseFlags

added in API level 10
fun getResponseFlags(): Byte

Return the Response Flag bytes from tag discovery.

Does not cause any RF activity and does not block.
Requires API level 10 (Android 2.3.3, Gingerbread)

Return
Byte: Response Flag bytes

getTag

added in API level 10
fun getTag(): Tag!

Get the Tag object backing this TagTechnology object.
Requires API level 10 (Android 2.3.3, Gingerbread) Requires API level 10 (Android 2.3.3, Gingerbread)

Return
Tag!: the Tag backing this TagTechnology object.

getDsfId

added in API level 10
fun getDsfId(): Byte

Return the DSF ID bytes from tag discovery.

Does not cause any RF activity and does not block.
Requires API level 10 (Android 2.3.3, Gingerbread)

Return
Byte: DSF ID bytes

connect

added in API level 10
fun connect(): Unit

Enable I/O operations to the tag from this 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 by calling #close from another thread.

Only one TagTechnology object can be connected to a Tag at a time.

Applications must call #close when I/O operations are complete.

Requires the android.Manifest.permission#NFC permission.
Requires API level 10 (Android 2.3.3, Gingerbread) Requires API level 10 (Android 2.3.3, Gingerbread)

Exceptions
TagLostException if the tag leaves the field
IOException if there is an I/O failure, or connect is canceled

getMaxTransceiveLength

added in API level 14
fun getMaxTransceiveLength(): Int

Return the maximum number of bytes that can be sent with #transceive.
Requires API level 14 (Android 4.0, IceCreamSandwich)

Return
Int: the maximum number of bytes that can be sent with #transceive.

close

added in API level 10
fun close(): Unit

Disable I/O operations to the tag from this TagTechnology object, and release resources.

Also causes all blocked I/O operations on other thread to be canceled and return with IOException.

Requires the android.Manifest.permission#NFC permission.
Requires API level 10 (Android 2.3.3, Gingerbread) Requires API level 10 (Android 2.3.3, Gingerbread)

Exceptions
Exception if this resource cannot be closed
IOException if an I/O error occurs

isConnected

added in API level 10
fun isConnected(): Boolean

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

Returns true if #connect has completed, and #close has not been called, and the Tag is not known to be out of range.

Does not cause RF activity, and does not block.
Requires API level 10 (Android 2.3.3, Gingerbread) Requires API level 10 (Android 2.3.3, Gingerbread)

Return
Boolean: true if I/O operations should be possible

get

added in API level 10
static fun get(tag: Tag!): NfcV!

Get an instance of NfcV for the given tag.

Returns null if NfcV was not enumerated in Tag#getTechList. This indicates the tag does not support NFC-V.

Does not cause any RF activity and does not block.
Requires API level 10 (Android 2.3.3, Gingerbread)

Parameters
tag Tag!: an NFC-V compatible tag
Return
NfcV!: NFC-V object