public final class NfcBarcode
extends Object implements TagTechnology
| java.lang.Object | |
| android.nfc.tech.NfcBarcode | |
提供对仅包含条形码的标签的访问。
使用 get(Tag)获取 NfcBarcode对象。
常量(Constants) |
|
|---|---|
int |
TYPE_KOVIO 科维奥标签 |
int |
TYPE_UNKNOWN |
公共方法(Public methods) |
|
|---|---|
void |
close() 禁用对来自此 |
void |
connect() 对来自此 |
static NfcBarcode |
get(Tag tag) 获取给定标签的 |
byte[] |
getBarcode() 返回NfcBarcode标签的条形码。 |
Tag |
getTag() 获取 |
int |
getType() 返回NFC条码标签类型。 |
boolean |
isConnected() 帮助者指出I / O操作是否可行。 |
继承方法(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 |
|
NfcBarcode get (Tag tag)
获取给定标签的实例 NfcBarcode 。
如果 NfcBarcode未在 getTechList()枚举,则返回null。
不会导致任何RF活动并且不会阻止。
| 参数(Parameters) | |
|---|---|
tag |
Tag: an NfcBarcode compatible tag |
| 返回(Returns) | |
|---|---|
NfcBarcode |
NfcBarcode object |
byte[] getBarcode ()
返回NfcBarcode标签的条形码。
TYPE_KOVIO标签返回16字节:
第一个字节是0x80 ORd,带有制造商ID,对应于ISO / IEC 7816-6。
第二个字节描述有效载荷数据格式。 定义的数据格式类型包括以下内容:
以下12个字节是有效载荷:
最后2个字节包含CRC。
不会导致任何RF活动并且不会阻止。
| 返回(Returns) | |
|---|---|
byte[] |
a byte array containing the barcode |
Tag getTag ()
获取 Tag对象支持此 TagTechnology对象。
| 返回(Returns) | |
|---|---|
Tag |
the Tag backing this TagTechnology object. |
int getType ()
返回NFC条码标签类型。
目前只有 TYPE_KOVIO或 TYPE_UNKNOWN 。
不会导致任何RF活动并且不会阻止。
| 返回(Returns) | |
|---|---|
int |
the NFC Barcode tag type |
boolean isConnected ()
帮助者指出I / O操作是否可行。
如果返回true connect()已经完成,并 close()没有被调用,并且 Tag不知道是超出范围。
不会导致射频活动,也不会阻止。
| 返回(Returns) | |
|---|---|
boolean |
true if I/O operations should be possible |