NfcBarcode
public
final
class
NfcBarcode
extends Object
implements
TagTechnology
java.lang.Object | |
↳ | android.nfc.tech.NfcBarcode |
Provides access to tags containing just a barcode.
Acquire an NfcBarcode
object using get(Tag)
.
Summary
Constants | |
---|---|
int |
TYPE_KOVIO
Kovio Tags |
int |
TYPE_UNKNOWN
|
Public methods | |
---|---|
void
|
close()
Disable I/O operations to the tag from this |
void
|
connect()
Enable I/O operations to the tag from this |
static
NfcBarcode
|
get(Tag tag)
Get an instance of |
byte[]
|
getBarcode()
Returns the barcode of an NfcBarcode tag. |
Tag
|
getTag()
Get the |
int
|
getType()
Returns the NFC Barcode tag type. |
boolean
|
isConnected()
Helper to indicate if I/O operations should be possible. |
Inherited methods | |
---|---|
Constants
TYPE_KOVIO
public static final int TYPE_KOVIO
Kovio Tags
Constant Value: 1 (0x00000001)
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN
Constant Value: -1 (0xffffffff)
Public methods
close
public void close ()
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 Manifest.permission.NFC
permission.
Throws | |
---|---|
IOException |
connect
public void connect ()
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 Manifest.permission.NFC
permission.
Throws | |
---|---|
IOException |
get
public static NfcBarcode get (Tag tag)
Get an instance of NfcBarcode
for the given tag.
Returns null if NfcBarcode
was not enumerated in Tag.getTechList
.
Does not cause any RF activity and does not block.
Parameters | |
---|---|
tag |
Tag : an NfcBarcode compatible tag |
Returns | |
---|---|
NfcBarcode |
NfcBarcode object |
getBarcode
public byte[] getBarcode ()
Returns the barcode of an NfcBarcode tag.
Tags of TYPE_KOVIO
return 16 bytes:
- 0x00: Reserved for manufacturer assignment
- 0x01: 96-bit URL with "http://www." prefix
- 0x02: 96-bit URL with "https://www." prefix
- 0x03: 96-bit URL with "http://" prefix
- 0x04: 96-bit URL with "https://" prefix
- 0x05: 96-bit GS1 EPC
- 0x06-0xFF: reserved
- In case of a URL payload, the payload is encoded in US-ASCII, following the limitations defined in RFC3987.
- In case of GS1 EPC data, see GS1 Electronic Product Code (EPC) Tag Data Standard (TDS) for more details.
The first byte is 0x80 ORd with a manufacturer ID, corresponding to ISO/IEC 7816-6.
The second byte describes the payload data format. Defined data format types include the following:
The following 12 bytes are payload:
The last 2 bytes comprise the CRC.
Does not cause any RF activity and does not block.
Returns | |
---|---|
byte[] |
a byte array containing the barcode |
getTag
public Tag getTag ()
Get the Tag
object backing this TagTechnology
object.
Returns | |
---|---|
Tag |
the Tag backing this TagTechnology object. |
getType
public int getType ()
Returns the NFC Barcode tag type.
Currently only one of TYPE_KOVIO
or TYPE_UNKNOWN
.
Does not cause any RF activity and does not block.
Returns | |
---|---|
int |
the NFC Barcode tag type |
isConnected
public boolean isConnected ()
Helper to indicate if I/O operations should be possible.
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.
Returns | |
---|---|
boolean |
true if I/O operations should be possible |