Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public final class

NfcB

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

Class Overview

Provides access to NFC-B (ISO 14443-3B) properties and I/O operations on a Tag .

Acquire a NfcB object using get(Tag) .

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

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 NfcB get ( Tag tag)
Get an instance of NfcB for the given tag.
byte[] getApplicationData ()
Return the Application Data bytes from ATQB/SENSB_RES at tag discovery.
int getMaxTransceiveLength ()
Return the maximum number of bytes that can be sent with transceive(byte[]) .
byte[] getProtocolInfo ()
Return the Protocol Info bytes from ATQB/SENSB_RES at tag discovery.
Tag getTag ()
Get the Tag object backing this TagTechnology object.
boolean isConnected ()
Helper to indicate if I/O operations should be possible.
byte[] transceive (byte[] data)
Send raw NFC-B commands 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
From interface java.lang.AutoCloseable

Public Methods

public void close ()

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.

public void connect ()

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.

public static NfcB get ( Tag tag)

Get an instance of NfcB for the given tag.

Returns null if NfcB was not enumerated in getTechList() . This indicates the tag does not support NFC-B.

Does not cause any RF activity and does not block.

Parameters
tag an NFC-B compatible tag
Returns
  • NFC-B object

public byte[] getApplicationData ()

Return the Application Data bytes from ATQB/SENSB_RES at tag discovery.

Does not cause any RF activity and does not block.

Returns
  • Application Data bytes from ATQB/SENSB_RES bytes

public int getMaxTransceiveLength ()

Return the maximum number of bytes that can be sent with transceive(byte[]) .

Returns

public byte[] getProtocolInfo ()

Return the Protocol Info bytes from ATQB/SENSB_RES at tag discovery.

Does not cause any RF activity and does not block.

Returns
  • Protocol Info bytes from ATQB/SENSB_RES bytes

public Tag getTag ()

Get the Tag object backing this TagTechnology object.

Returns

public boolean isConnected ()

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 byte[] transceive (byte[] data)

Send raw NFC-B 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 not send commands that manage the polling loop and initialization (SENSB_REQ, SLOT_MARKER etc).

Use getMaxTransceiveLength() to retrieve the maximum number of bytes that can be sent with 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 if close() is called from another thread.

Requires the NFC permission.

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