Skip to content

Commit ddbb2c9

Browse files
author
Nick Pelly
committed
Tweak Ndef.getType() API. Rename constants, expand javadoc.
Change-Id: I9d2c83411411fea4ef46bb7c30ebdbcd9ee3e7d8
1 parent d27ebf1 commit ddbb2c9

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

core/java/android/nfc/technology/Ndef.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ public final class Ndef extends BasicTagTechnology {
5757
/** @hide */
5858
public static final String EXTRA_NDEF_TYPE = "ndeftype";
5959

60-
public static final int UNKNOWN_TAG = 0;
61-
public static final int TYPE1_TAG = 1;
62-
public static final int TYPE2_TAG = 2;
63-
public static final int TYPE3_TAG = 3;
64-
public static final int TYPE4_TAG = 4;
65-
public static final int MIFARE_CLASSIC_TAG = 5;
60+
//TODO: consider removing OTHER entirely - and not allowing Ndef to
61+
// enumerate for tag types outside of (NFC Forum 1-4, MifareClassic)
62+
public static final int OTHER = -1;
63+
public static final int NFC_FORUM_TYPE_1 = 1;
64+
public static final int NFC_FORUM_TYPE_2 = 2;
65+
public static final int NFC_FORUM_TYPE_3 = 3;
66+
public static final int NFC_FORUM_TYPE_4 = 4;
67+
public static final int MIFARE_CLASSIC = 105;
6668

6769
private final int mMaxNdefSize;
6870
private final int mCardState;
@@ -104,7 +106,18 @@ public NdefMessage[] getExtraNdefMessage() throws IOException, FormatException {
104106
}
105107

106108
/**
107-
* Get NDEF card type
109+
* Get NDEF tag type.
110+
* <p>Returns one of {@link #NFC_FORUM_TYPE_1}, {@link #NFC_FORUM_TYPE_2},
111+
* {@link #NFC_FORUM_TYPE_3}, {@link #NFC_FORUM_TYPE_4},
112+
* {@link #MIFARE_CLASSIC} or {@link #OTHER}.
113+
* <p>Platforms of this API revision will always return one of the above
114+
* values. Platforms at future API revisions may return other values, which
115+
* can be treated as {@link #OTHER} by applications targeting this API.
116+
* <p>Android devices with NFC support must always correctly enumerate
117+
* NFC Forum tag types, and may optionally enumerate
118+
* {@link #MIFARE_CLASSIC} since it requires proprietary technology.
119+
* Devices that cannot enumerate {@link #MIFARE_CLASSIC} will use
120+
* {@link #OTHER} instead.
108121
*/
109122
public int getType() {
110123
return mNdefType;

0 commit comments

Comments
 (0)