public interface TagTechnology
implements Closeable
android.nfc.tech.TagTechnology |
Known Indirect Subclasses |
TagTechnology
处于一个技术接口 Tag
。
通过调用实现类的静态方法 get()
获得 TagTechnology
实现。
NFC标签基于许多独立开发的技术,并提供广泛的功能。 TagTechnology
实现提供对这些不同技术和功能的访问。 一些子类映射到技术规范(例如NfcA
, IsoDep
,其他映射到伪技术或能力(例如Ndef
, NdefFormatable
)。
所有Android NFC设备都必须提供以下 TagTechnology
实现。
NfcA
(also known as ISO 14443-3A) NfcB
(also known as ISO 14443-3B) NfcF
(also known as JIS 6319-4) NfcV
(also known as ISO 15693) IsoDep
Ndef
on NFC Forum Type 1, Type 2, Type 3 or Type 4 compliant tags TagTechnology
implementations. If it is not provided, the Android device will never enumerate that class via
getTechList()
.
MifareClassic
MifareUltralight
NfcBarcode
NdefFormatable
must only be enumerated on tags for which this Android device is capable of formatting. Proprietary knowledge is often required to format a tag to make it NDEF compatible. TagTechnology
实现提供的方法分为两类: 缓存的getter和 I / O操作 。
get
or
is
) return properties of the tag, as determined at discovery time. These methods will never block or cause RF activity, and do not require
connect()
to have been called. They also never update, for example if a property is changed by an I/O operation with a tag then the cached getter will still return the result from tag discovery time.
connect()
must be called before using any other I/O operation. close()
must be called after completing I/O operations with a TagTechnology
, and it will cancel all other blocked I/O operations on other threads (including connect()
with IOException
. TagTechnology
can be connected at a time. Other calls to connect()
will return IOException
. 注意:执行I / O操作的方法需要 NFC
权限。
Public methods |
|
---|---|
abstract void |
close() 禁用对来自此 |
abstract void |
connect() 启用来自此 |
abstract Tag |
getTag() 获取 |
abstract boolean |
isConnected() 帮助者指出I / O操作是否可行。 |
Inherited methods |
|
---|---|
From interface java.io.Closeable
|
|
From interface java.lang.AutoCloseable
|
void close ()
禁用对来自此 TagTechnology
对象的标记的I / O操作,并释放资源。
还会导致其他线程上的所有阻塞的I / O操作被取消,并返回 IOException
。
需要 NFC
权限。
Throws | |
---|---|
IOException |
也可以看看:
void connect ()
对来自此 TagTechnology
对象的标记启用I / O操作。
可能导致RF活动并可能阻塞。 不能从主应用程序线程调用。 通过从另一个线程呼叫close()
,被阻止的呼叫将被IOException
取消。
一次只能将一个 TagTechnology
对象连接到 Tag
。
当I / O操作完成时,应用程序必须调用 close()
。
需要 NFC
权限。
Throws | |
---|---|
|
if the tag leaves the field |
IOException |
if there is an I/O failure, or connect is canceled |
也可以看看:
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 |