Added missing implementation for NdefRecord.
Implemented constructor using a byte array to parse.
Added missing exception in method declaration, leading to update api/current.xml
Change-Id: I2660484aef1225e90c2f32a572041a2c3aecf288
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index 23fd2ca..edc5ab9 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -200,8 +200,17 @@
*
* @throws FormatException if the data is not a valid NDEF record
*/
- public NdefRecord(byte[] data) {
- throw new UnsupportedOperationException();
+ public NdefRecord(byte[] data) throws FormatException {
+ /* Prevent compiler to complain about unassigned final fields */
+ mFlags = 0;
+ mTnf = 0;
+ mType = null;
+ mId = null;
+ mPayload = null;
+ /* Perform actual parsing */
+ if (parseNdefRecord(data) == -1) {
+ throw new FormatException("Error while parsing NDEF record");
+ }
}
/**
@@ -280,5 +289,6 @@
}
};
+ private native int parseNdefRecord(byte[] data);
private native byte[] generate(short flags, short tnf, byte[] type, byte[] id, byte[] data);
}
\ No newline at end of file