ReaderService
com.rvi.service.ReaderService · Class · SocialCard 1.0.3
Discover PC/SC readers and open a connection to a tag.
When to use it
Section titled “When to use it”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().
Java example
Section titled “Java example”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.
How it works
Section titled “How it works”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.
Related API
Section titled “Related API”IReaderService · ReaderRepository · ReaderMonitor · ReaderServiceException