Skip to main content

Reader Mode

Reader mode can be used to active scan for tags and read them multiple times. This is useful in the cases where the data changes on the tag so you may need to re-read it at a later point.

info

It is important to note that using reader mode may interfere with the other NFC operations of the device, disabling any peer-to-peer (Android Beam) and card-emulation modes of the NFC adapter on this device.

Start scanning

To initiate reader mode call enableReaderMode():

NFC.service.enableReaderMode();

While active any detected tags will dispatch a NFCEvent.ACTION_NDEF_DISCOVERED event:

NFC.service.addEventListener( NFCEvent.ACTION_NDEF_DISCOVERED, discoveredHandler );

function discoveredHandler( event:NFCEvent ):void
{
// ndef tag detected
}

Stop scanning

You should make sure to disable reader mode once you have completed scanning by calling disableReaderMode():

NFC.service.disableReaderMode();

Restart scanning

If you have scanned a tag and wish to re-read it, you will need to call restart() to invalidate any scanned tags and rescan them:

NFC.service.restart();

If a tag scanned previously is still within range then another NFCEvent.ACTION_NDEF_DISCOVERED event will be dispatched with the latest payload data.