public class NdefTag extends TagManager
NdefTag object, control connections to the NDEF tag,
and read data from and write data to the NDEF tag.
This class inherits from TagManager.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
NDEF_TYPE_1 |
Indicates the NDEF tag of type 1.
|
static String |
NDEF_TYPE_2 |
Indicates the NDEF tag of type 2.
|
static String |
NDEF_TYPE_3 |
Indicates the NDEF tag of type 3.
|
static String |
NDEF_TYPE_4 |
Indicates the NDEF tag of type 4.
|
static String |
NDEF_TYPE_ICODE_SLI |
Indicates the NDEF tag of the iCODE SLI type.
|
static String |
NDEF_TYPE_MIFARE_CLASSIC |
Indicates the NDEF tag of the Mifare Classic type..
|
ISO_DEP, MIFARE_CLASSIC, MIFARE_ULTRALIGHT, NDEF, NFC_A, NFC_B, NFC_F, NFC_V| 构造器 | 说明 |
|---|---|
NdefTag(TagInfo tagInfo) |
Obtains an
NdefTag object based on the given tag information. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
canSetReadOnly() |
Checks whether this NDEF tag can be set to read-only.
|
static Optional<NdefTag> |
getInstance(TagInfo tagInfo) |
Obtains an instance of
NdefTag object based on the given tag information. |
int |
getNdefMaxSize() |
Obtains the maximum NDEF message size.
|
NdefMessage |
getNdefMessage() |
Obtains the NDEF message from this NDEF tag.
|
String |
getTagType() |
Obtains the NDEF tag type.
|
boolean |
isNdefWritable() |
Checks whether the NDEF tag is writable.
|
NdefMessage |
readNdefMessage() |
Reads the NDEF message from currently connected tag.
|
boolean |
setReadOnly() |
Sets the NDEF tag to read-only.
|
void |
writeNdefMessage(NdefMessage msg) |
Writes the NDEF message to currently connected NDEF tag.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcheckConnected, connectTag, getMaxSendLength, getSendDataTimeout, getTagInfo, isTagConnected, reset, sendData, setSendDataTimeoutpublic static final String NDEF_TYPE_1
public static final String NDEF_TYPE_2
public static final String NDEF_TYPE_3
public static final String NDEF_TYPE_4
public static final String NDEF_TYPE_ICODE_SLI
public NdefTag(TagInfo tagInfo)
NdefTag object based on the given tag information.
If the given tag is NDEF formatted, an NdefTag object will be created based on the
given tag information; otherwise, an empty NdefTag object will be created.
tagInfo - Indicates the information about the given tag.public static Optional<NdefTag> getInstance(TagInfo tagInfo)
NdefTag object based on the given tag information.
If the given tag is NDEF formatted, an NdefTag object will be created based on the
given tag information; otherwise, an empty NdefTag object will be created.
tagInfo - Indicates the information about the given tag.public NdefMessage getNdefMessage()
public int getNdefMaxSize()
public String getTagType()
NDEF_TYPE_1, NDEF_TYPE_2,
NDEF_TYPE_3, and NDEF_TYPE_4.public NdefMessage readNdefMessage() throws IOException, IllegalArgumentException
IOException - if there is an I/O failure, or the operation is canceled.IllegalArgumentException - if the NDEF Message on the tag is malformed.RemoteException - if read the NDEF failed.public void writeNdefMessage(NdefMessage msg) throws IOException, IllegalArgumentException
msg - Indicates the NDEF message to write, must not be null.IOException - if there is an I/O failure, or the operation is canceled.IllegalArgumentException - if the NDEF Message to write is malformed.RemoteException - if write NDEF Message failed.public boolean canSetReadOnly()
true if this NDEF tag can be set to read-only;
returns false otherwise.public boolean setReadOnly()
throws IOException
true if the NDEF tag is set to read-only; returns false otherwise.IOException - if there is an I/O failure, or the operation is canceled.public boolean isNdefWritable()
true if the NDEF tag is writable; returns false otherwise.