Example usage for Java android.nfc NdefMessage fields, constructors, methods, implement or subclass
The text is from its open source code.
NdefMessage(byte[] data) Construct an NDEF Message by parsing raw bytes. Strict validation of the NDEF binary structure is performed: there must be at least one record, every record flag must be correct, and the total length of the message must match the length of the input data. This parser can handle chunked records, and converts them into logical NdefRecord s within the message. Once the input data has been parsed to one or more logical records, basic validation of the tnf, type, id, and payload fields of each record is performed, as per the documentation on on NdefRecord#NdefRecord(short,byte[],byte[],byte[]) If either strict validation of the binary format fails, or basic validation during record construction fails, a FormatException is thrown Deep inspection of the type, id and payload fields of each record is not performed, so it is possible to parse input that has a valid binary format and confirms to the basic validation requirements of NdefRecord#NdefRecord(short,byte[],byte[],byte[]) , but fails more strict requirements as specified by the NFC Forum. | |
NdefMessage(NdefRecord[] records) Construct an NDEF Message from one or more NDEF Records. | |
NdefMessage(NdefRecord record, NdefRecord... records) Construct an NDEF Message from one or more NDEF Records. |
int | getByteArrayLength() Return the length of this NDEF Message if it is written to a byte array with #toByteArray . An NDEF Message can be formatted to bytes in different ways depending on chunking, SR, and ID flags, so the length returned by this method may not be equal to the length of the original byte array used to construct this NDEF Message. |
NdefRecord[] | getRecords() Get the NDEF Records inside this NDEF Message. An NdefMessage always has one or more NDEF Records: so the following code to retrieve the first record is always safe (no need to check for null or array length >= 1): NdefRecord firstRecord = ndefMessage.getRecords()[0]; |
byte[] | toByteArray() Return this NDEF Message as raw bytes. The NDEF Message is formatted as per the NDEF 1.0 specification, and the byte array is suitable for network transmission or storage in an NFC Forum NDEF compatible tag. This method will not chunk any records, and will always use the short record (SR) format and omit the identifier field when possible. |
String | toString() |