public interface TagTechnology extends Closeable
TagTechnology
is an interface to a technology in a Tag
.
Obtain a TagTechnology
implementation by calling the static method get()
on the implementation class.
NFC tags are based on a number of independently developed technologies and offer a
wide range of capabilities. The
TagTechnology
implementations provide access to these different
technologies and capabilities. Some sub-classes map to technology
specification (for example NfcA
, IsoDep
, others map to
pseudo-technologies or capabilities (for example Ndef
, NdefFormatable
).
It is mandatory for all Android NFC devices to provide the following
TagTechnology
implementations.
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 Tag.getTechList()
.
MifareClassic
MifareUltralight
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
implementations provide methods that fall into two classes:
cached getters and I/O operations.
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
.
Note: Methods that perform I/O operations
require the android.Manifest.permission#NFC
permission.
Modifier and Type | Field and Description |
---|---|
static int |
ISO_DEP
This technology is an instance of
IsoDep . |
static int |
MIFARE_CLASSIC
This technology is an instance of
MifareClassic . |
static int |
MIFARE_ULTRALIGHT
This technology is an instance of
MifareUltralight . |
static int |
NDEF
This technology is an instance of
Ndef . |
static int |
NDEF_FORMATABLE
This technology is an instance of
NdefFormatable . |
static int |
NFC_A
This technology is an instance of
NfcA . |
static int |
NFC_B
This technology is an instance of
NfcB . |
static int |
NFC_BARCODE
This technology is an instance of
NfcBarcode . |
static int |
NFC_F
This technology is an instance of
NfcF . |
static int |
NFC_V
This technology is an instance of
NfcV . |
Modifier and Type | Method and Description |
---|---|
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. |
Tag |
getTag()
Get the
Tag object backing this TagTechnology object. |
boolean |
isConnected()
Helper to indicate if I/O operations should be possible.
|
void |
reconnect()
Re-connect to the
Tag associated with this connection. |
static final int NFC_A
NfcA
.
Support for this technology type is mandatory.
static final int NFC_B
NfcB
.
Support for this technology type is mandatory.
static final int ISO_DEP
IsoDep
.
Support for this technology type is mandatory.
static final int NFC_F
NfcF
.
Support for this technology type is mandatory.
static final int NFC_V
NfcV
.
Support for this technology type is mandatory.
static final int NDEF
Ndef
.
Support for this technology type is mandatory.
static final int NDEF_FORMATABLE
NdefFormatable
.
Support for this technology type is mandatory.
static final int MIFARE_CLASSIC
MifareClassic
.
Support for this technology type is optional. If a stack doesn't support this technology type tags using it must still be discovered and present the lower level radio interface technologies in use.
static final int MIFARE_ULTRALIGHT
MifareUltralight
.
Support for this technology type is optional. If a stack doesn't support this technology type tags using it must still be discovered and present the lower level radio interface technologies in use.
static final int NFC_BARCODE
NfcBarcode
.
Support for this technology type is optional. If a stack doesn't support this technology type tags using it must still be discovered and present the lower level radio interface technologies in use.
Tag getTag()
Tag
object backing this TagTechnology
object.Tag
backing this TagTechnology
object.void connect() throws IOException
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 android.Manifest.permission#NFC
permission.
TagLostException
- if the tag leaves the fieldIOException
- if there is an I/O failure, or connect is canceledclose()
void reconnect() throws IOException
Tag
associated with this connection. Reconnecting to a tag can be
used to reset the state of the tag itself.
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.
Requires the android.Manifest.permission#NFC
permission.
TagLostException
- if the tag leaves the fieldIOException
- if there is an I/O failure, or connect is canceledconnect()
,
close()
void close() throws IOException
TagTechnology
object, and release resources.
Also causes all blocked I/O operations on other thread to be canceled and
return with IOException
.
Requires the android.Manifest.permission#NFC
permission.
close
in interface AutoCloseable
close
in interface Closeable
IOException
connect()
boolean isConnected()
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.