Skip to content

ReaderListener

com.rvi.application.ReaderListener · Class · SocialCard 1.0.3

Write a predefined NDEF message on each insertion event.

Use this concrete listener for a dedicated station where inserting a tag means it should be overwritten. For a UI that asks the user to confirm each write, implement IReaderListener and perform the write after confirmation.

static ReaderMonitor startWritingStation(final CardTerminal terminal) {
final NDefMessage message = new NDefEncoder().encodeURI("https://rithush.dev");
final ReaderMonitor monitor = new ReaderMonitor(terminal, new ReaderListener(message));
monitor.start();
return monitor;
}
Java imports
import com.rvi.application.NDefEncoder;
import com.rvi.application.ReaderListener;
import com.rvi.application.ReaderMonitor;
import com.rvi.domain.NDefMessage;
import javax.smartcardio.CardTerminal;

Run this only with test tags or tags intended for the station. The caller closes the returned monitor.

On insertion it creates a ReaderService for the terminal, connects, writes the message and closes the service. It logs success after verification, logs removal events and forwards runtime failures to its logging onError() callback.

IReaderListener · ReaderMonitor · ReaderService

Method signatures in the Javadoc · All API types