public final class NfcB
extends Object implements TagTechnology
| java.lang.Object | |
| android.nfc.tech.NfcB | |
提供对Tag的NFC-B(ISO 14443-3B)属性和I / O操作的 Tag 。
主要的NFC-B I / O操作是transceive(byte[]) 。 应用程序必须在transceive(byte[])之上实现自己的协议栈。
注意:执行I / O操作的方法需要 NFC权限。
公共方法(Public methods) |
|
|---|---|
void |
close() 禁用对来自此 |
void |
connect() 对来自此 |
static NfcB |
get(Tag tag) 获取给定标签的实例 |
byte[] |
getApplicationData() 在标签发现时从ATQB / SENSB_RES返回应用数据字节。 |
int |
getMaxTransceiveLength() 返回可用 |
byte[] |
getProtocolInfo() 在标签发现时从ATQB / SENSB_RES返回协议信息字节。 |
Tag |
getTag() 获取 |
boolean |
isConnected() 帮助者指出I / O操作是否可行。 |
byte[] |
transceive(byte[] data) 发送原始NFC-B命令到标签并接收响应。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
android.nfc.tech.TagTechnology
|
|
java.io.Closeable
|
|
java.lang.AutoCloseable
|
|
void close ()
禁用对来自此 TagTechnology对象的标记的I / O操作,并释放资源。
也会导致其他线程上的所有被阻止的I / O操作被取消,并返回 IOException 。
需要 NFC权限。
| 抛出异常(Throws) | |
|---|---|
IOException |
|
void connect ()
启用来自此 TagTechnology对象的标记的I / O操作。
可能导致RF活动并可能阻塞。 不能从主应用程序线程调用。 IOException通过从另一个线程调用close()来取消被阻止的呼叫。
一次只能将一个 TagTechnology对象连接到 Tag 。
当I / O操作完成时,应用程序必须调用 close() 。
需要 NFC权限。
| 抛出异常(Throws) | |
|---|---|
IOException |
|
NfcB get (Tag tag)
为给定标签获取 NfcB的实例。
如果未在getTechList()列举NfcB则返回null。 这表示该标签不支持NFC-B。
不会导致任何RF活动并且不会阻止。
| 参数(Parameters) | |
|---|---|
tag |
Tag: an NFC-B compatible tag |
| 返回(Returns) | |
|---|---|
NfcB |
NFC-B object |
byte[] getApplicationData ()
在标签发现时从ATQB / SENSB_RES返回应用数据字节。
不会导致任何RF活动并且不会阻止。
| 返回(Returns) | |
|---|---|
byte[] |
Application Data bytes from ATQB/SENSB_RES bytes |
int getMaxTransceiveLength ()
返回可以用 transceive(byte[])发送的最大字节数。
| 返回(Returns) | |
|---|---|
int |
the maximum number of bytes that can be sent with transceive(byte[]). |
byte[] getProtocolInfo ()
在标签发现时从ATQB / SENSB_RES返回协议信息字节。
不会导致任何RF活动并且不会阻止。
| 返回(Returns) | |
|---|---|
byte[] |
Protocol Info bytes from ATQB/SENSB_RES bytes |
Tag getTag ()
获取 Tag对象支持此 TagTechnology对象。
| 返回(Returns) | |
|---|---|
Tag |
the Tag backing this TagTechnology object. |
boolean isConnected ()
帮助者指出I / O操作是否可行。
如果返回true connect()已经完成,并 close()没有被调用,并且 Tag不知道是超出范围。
不会导致射频活动,也不会阻止。
| 返回(Returns) | |
|---|---|
boolean |
true if I/O operations should be possible |
byte[] transceive (byte[] data)
发送原始NFC-B命令到标签并接收响应。
应用程序不能将EoD(CRC)附加到有效负载,它将自动计算。
应用程序不得发送管理轮询循环和初始化的命令(SENSB_REQ,SLOT_MARKER等)。
使用 getMaxTransceiveLength()检索可通过 transceive(byte[])发送的最大字节数。
这是一个I / O操作,将阻塞直到完成。 它不能从主应用程序线程调用。 如果从另一个线程调用close()被阻止的呼叫将被IOException取消。
需要 NFC权限。
| 参数(Parameters) | |
|---|---|
data |
byte: bytes to send |
| 返回(Returns) | |
|---|---|
byte[] |
bytes received in response |
| 抛出异常(Throws) | |
|---|---|
|
if the tag leaves the field |
IOException |
if there is an I/O failure, or this operation is canceled |