Skip to content

ReaderService

com.rvi.service.ReaderService · Class · SocialCard 1.0.3

Discover PC/SC readers and open a connection to a tag.

Choose a reader from listReaders() if several devices are connected. Pass its exact name to create(name), or use create() to select the first reader at connection time. Place a tag on the reader before calling connect().

final List<String> readers = ReaderService.listReaders();
if (readers.isEmpty()) {
System.out.println("Connect a PC/SC reader first.");
return;
}
try (final IReaderService reader = ReaderService.create(readers.getFirst())) {
reader.connect();
System.out.println(reader.readURIs());
}
Java imports
import com.rvi.service.IReaderService;
import com.rvi.service.ReaderService;
import java.util.List;

This example reads a tag. Run it with a readable NDEF tag already in place.

The factories return a disconnected service. On connect, the service opens the card channel and delegates reads and writes to ReaderRepository. createForTerminal(terminal) uses a CardTerminal you already have, for example one received from ReaderMonitor. For tests of service code, the public constructor accepts an IReaderRepository.

IReaderService · ReaderRepository · ReaderMonitor · ReaderServiceException

Method signatures in the Javadoc · All API types