NfcReaderMode
Reader mode, the platform's NFC dispatch an Android chip read runs on: NfcChipRead is the callback.
The rules (the platform facts behind them are in its NfcActivityManager and NfcService source):
Call enable once for each read, with that read, while the read screen is shown: from
onCreateoronResume, on the main thread. Reader mode belongs to that Activity: the platform turns it off when the Activity pauses and on again, with the same callback, when it resumes. So do not call enable again in everyonResume, and after a configuration change call it once for the new Activity.Never switch reader mode off and on while a document may be on the phone: switching it off drops the link, and the read sees a lost link. Call disable when the read screen is left for good, after the read ended or was cancelled.
Do not use
NfcAdapter.ignoreto keep a document from being found again: the platform documentation says it does not work reliably with tags that have a random ID, and passport chips use one.An Activity has one reader mode. enable replaces any reader mode your app turned on for the same Activity (its callback hears no tag after that), and disable turns reader mode off for the Activity, whoever turned it on. The platform has no call that tells whether an Activity already has reader mode on, so the SDK cannot see or report it: turn your own reader mode off before a chip read, and on again after its ending if you need it.
Experimental: see ExperimentalTesseraChipApi.
Since
1.0.0
Properties
Functions
Whether NFC can be used right now, before a read starts.
Turns reader mode on for activity, with callback as the one who hears every discovered tag: pass the NfcChipRead. Call it once for each read, while the read screen is shown, on the main thread.