java.lang.Object | |
↳ | android.nfc.tech.NdefFormatable |
Provide access to NDEF format operations on a Tag
.
Acquire a NdefFormatable
object using get(Tag)
.
Android devices with NFC must only enumerate and implement this class for tags for which it can format to NDEF.
Unfortunately the procedures to convert unformated tags to NDEF formatted
tags are not specified by NFC Forum, and are not generally well-known. So
there is no mandatory set of tags for which all Android devices with NFC
must support NdefFormatable
.
Note: Methods that perform I/O operations
require the NFC
permission.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Disable I/O operations to the tag from this
TagTechnology object, and release resources. | |||||||||||
Enable I/O operations to the tag from this
TagTechnology object. | |||||||||||
Format a tag as NDEF, and write a
NdefMessage . | |||||||||||
Formats a tag as NDEF, write a
NdefMessage , and make read-only. | |||||||||||
Get an instance of
NdefFormatable for the given tag. | |||||||||||
Get the
Tag object backing this TagTechnology object. | |||||||||||
Helper to indicate if I/O operations should be possible.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.nfc.tech.TagTechnology
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.lang.AutoCloseable
|
Disable I/O operations to the tag from this TagTechnology
object, and release resources.
Also causes all blocked I/O operations on other thread to be canceled and
return with IOException
.
Requires the NFC
permission.
IOException |
---|
Enable I/O operations to the tag from this 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 NFC
permission.
IOException |
---|
Format a tag as NDEF, and write a NdefMessage
.
This is a multi-step process, an IOException is thrown if any one step fails.
The card is left in a read-write state after this operation.
This is an I/O operation and will block until complete. It must
not be called from the main application thread. A blocked call will be canceled with
IOException
if close()
is called from another thread.
Requires the NFC
permission.
firstMessage | the NDEF message to write after formatting, can be null |
---|
TagLostException | if the tag leaves the field |
---|---|
IOException | if there is an I/O failure, or the operation is canceled |
FormatException | if the NDEF Message to write is malformed |
Formats a tag as NDEF, write a NdefMessage
, and make read-only.
This is a multi-step process, an IOException is thrown if any one step fails.
The card is left in a read-only state if this method returns successfully.
This is an I/O operation and will block until complete. It must
not be called from the main application thread. A blocked call will be canceled with
IOException
if close()
is called from another thread.
Requires the NFC
permission.
firstMessage | the NDEF message to write after formatting |
---|
TagLostException | if the tag leaves the field |
---|---|
IOException | if there is an I/O failure, or the operation is canceled |
FormatException | if the NDEF Message to write is malformed |
Get an instance of NdefFormatable
for the given tag.
Does not cause any RF activity and does not block.
Returns null if NdefFormatable
was not enumerated in getTechList()
.
This indicates the tag is not NDEF formatable by this Android device.
tag | an NDEF formatable tag |
---|
Get the Tag
object backing this TagTechnology
object.
Tag
backing this TagTechnology
object.