public final class

IsoDep

extends Object
implements TagTechnology
java.lang.Object
   ↳ android.nfc.tech.IsoDep

Class Overview

Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations on a Tag.

Acquire an IsoDep object using get(Tag).

The primary ISO-DEP I/O operation is transceive(byte[]). Applications must implement their own protocol stack on top of transceive(byte[]).

Tags that enumerate the IsoDep technology in getTechList() will also enumerate NfcA or NfcB (since IsoDep builds on top of either of these).

Note: Methods that perform I/O operations require the NFC permission.

Summary

Public Methods
void close()
Disable I/O operations to the tag from this TagTechnology object, and release resources.
void connect()
Enable I/O operations to the tag from this TagTechnology object.
static IsoDep get(Tag tag)
Get an instance of IsoDep for the given tag.
byte[] getHiLayerResponse()
Return the higher layer response bytes for NfcB tags.
byte[] getHistoricalBytes()
Return the ISO-DEP historical bytes for NfcA tags.
Tag getTag()
Get the Tag object backing this TagTechnology object.
boolean isConnected()
Helper to indicate if I/O operations should be possible.
void setTimeout(int timeout)
Set the timeout of transceive(byte[]) in milliseconds.
byte[] transceive(byte[] data)
Send raw ISO-DEP data to the tag and receive the response.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.nfc.tech.TagTechnology
From interface java.io.Closeable

Public Methods

public void close ()

Since: API Level 10

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 NFC permission.

Throws
IOException

public void connect ()

Since: API Level 10

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 NFC permission.

Throws
IOException

public static IsoDep get (Tag tag)

Since: API Level 10

Get an instance of IsoDep for the given tag.

Does not cause any RF activity and does not block.

Returns null if IsoDep was not enumerated in getTechList(). This indicates the tag does not support ISO-DEP.

Parameters
tag an ISO-DEP compatible tag
Returns
  • ISO-DEP object

public byte[] getHiLayerResponse ()

Since: API Level 10

Return the higher layer response bytes for NfcB tags.

Does not cause any RF activity and does not block.

The higher layer response bytes can be used to help identify a tag. They are present only on IsoDep tags that are based on NfcB RF technology. If this tag is not NfcB then null is returned.

In ISO 14443-4 terminology, the higher layer bytes are a subset of the ATTRIB response.

Returns
  • ISO-DEP historical bytes, or null if this is not a NfcB tag

public byte[] getHistoricalBytes ()

Since: API Level 10

Return the ISO-DEP historical bytes for NfcA tags.

Does not cause any RF activity and does not block.

The historical bytes can be used to help identify a tag. They are present only on IsoDep tags that are based on NfcA RF technology. If this tag is not NfcA then null is returned.

In ISO 14443-4 terminology, the historical bytes are a subset of the RATS response.

Returns
  • ISO-DEP historical bytes, or null if this is not a NfcA tag

public Tag getTag ()

Since: API Level 10

Get the Tag object backing this TagTechnology object.

Returns

public boolean isConnected ()

Since: API Level 10

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.

Returns
  • true if I/O operations should be possible

public void setTimeout (int timeout)

Since: API Level 10

Set the timeout of transceive(byte[]) in milliseconds.

The timeout only applies to ISO-DEP transceive(byte[]), and is reset to a default value when 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 NFC permission.

Parameters
timeout timeout value in milliseconds

public byte[] transceive (byte[] data)

Since: API Level 10

Send raw ISO-DEP data to the tag and receive the response.

Applications must only send the INF payload, and not the start of frame and end of frame indicators. Applications do not need to fragment the payload, it will be automatically fragmented and defragmented by transceive(byte[]) if it exceeds FSD/FSC limits.

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 NFC permission.

Parameters
data command bytes to send, must not be null
Returns
  • response bytes received, will not be null
Throws
if the tag leaves the field
IOException if there is an I/O failure, or this operation is canceled