Class NfcReadOptions
java.lang.Object
com.codename1.nfc.NfcReadOptions
Configures a single call to Nfc.readTag(NfcReadOptions) or
Nfc.addTagListener(NfcListener). Setters return this for fluent
chaining; every property has a useful default.
Not every option is honoured on every platform -- iOS displays the
system NFC sheet whose copy comes from setAlertMessage(String) but
ignores setTechFilter(TagType...) since Core NFC chooses session type
from the entitlement. Unrecognised settings are silently ignored, so
callers can set the union without platform if statements.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe current message shown on iOS Core NFC's system sheet.FeliCa system codes to scan for (e.g.["0003", "8008"]).Message shown on the iOS sheet after the session is invalidated because of an error, ornullto leave it unset.List<byte[]> ISO 7816 AIDs the iOS reader session auto-SELECTs on connection.The currently configured technology filter.longSession timeout in milliseconds.booleantruewhen the session is restricted to tags that already carry an NDEF payload.setAlertMessage(String alertMessage) Sets the message shown on iOS Core NFC's modal sheet while the session is active.setFelicaSystemCodes(String... codes) Sets the FeliCa system codes the iOS reader session looks for.setInvalidatedMessage(String invalidatedMessage) Sets the message shown on the iOS sheet after the session ends in failure.setIsoSelectAids(byte[]... aids) Sets the ISO 7816 AIDs the iOS reader session auto-SELECTs on connection.setNdefOnly(boolean ndefOnly) Restricts the session to NDEF-formatted tags.setTechFilter(TagType... types) Restricts the reader session to the listed technologies.setTimeoutMs(long timeoutMs) Stops the session automatically after the given duration.
-
Constructor Details
-
NfcReadOptions
public NfcReadOptions()
-
-
Method Details
-
getAlertMessage
The current message shown on iOS Core NFC's system sheet. Defaults to"Hold your iPhone near the NFC tag". Ignored on Android (no system sheet) and on the fallback base class. -
setAlertMessage
Sets the message shown on iOS Core NFC's modal sheet while the session is active. Translate this string for your locale before callingNfc.readTag(NfcReadOptions). Ignored on Android. -
getInvalidatedMessage
Message shown on the iOS sheet after the session is invalidated because of an error, ornullto leave it unset. Ignored on Android. -
setInvalidatedMessage
Sets the message shown on the iOS sheet after the session ends in failure. Ignored on Android. -
getTechFilter
-
setTechFilter
Restricts the reader session to the listed technologies. On Android the foreground-dispatch intent filter is computed from this list. iOS picks the underlying session type (NFCNDEFReaderSessionforTagType.NDEFonly, otherwiseNFCTagReaderSession). -
isNdefOnly
public boolean isNdefOnly()truewhen the session is restricted to tags that already carry an NDEF payload. Shortcut for settingsetTechFilter(TagType...)to[NDEF]. iOS uses this to pickNFCNDEFReaderSessioninstead ofNFCTagReaderSession. -
setNdefOnly
Restricts the session to NDEF-formatted tags. This is the fastest / most permissive iOS Core NFC mode and the only one that does not require theNFCReaderSessionentitlement on iOS 13. -
getTimeoutMs
public long getTimeoutMs()Session timeout in milliseconds.0means "no timeout" (the default); the session ends only when the user dismisses it or a tag is read. On iOS Core NFC the session is hard-capped at 60 seconds regardless of this value. -
setTimeoutMs
Stops the session automatically after the given duration. Honoured on Android and on the JavaSE simulator; iOS Core NFC always uses its own 60-second hard limit. -
getFelicaSystemCodes
-
setFelicaSystemCodes
Sets the FeliCa system codes the iOS reader session looks for. Ignored on Android. -
getIsoSelectAids
ISO 7816 AIDs the iOS reader session auto-SELECTs on connection. Each AID must be a 5-16 byte byte array. Honoured only on iOS where the AIDs must also appear incom.apple.developer.nfc.readersession.iso7816.select-identifiers. -
setIsoSelectAids
Sets the ISO 7816 AIDs the iOS reader session auto-SELECTs on connection. The bytes are defensively copied. Ignored on Android.
-