To summarize the various issues in the initial post:
- Reading or writing from/to blocks bejond the tag size will result in IOExceptions caused by the tag stopping to respond.
NfcV.getMaxTransceiveLength()
returns information about the maximum number of bytes that can be exchanged in one command/one response. It does not provide information about the tag size!.- Unfortunately there is no one-for-all approach to detect the actual size of a tag. A possible approach would be to try to detect the type of tag (many NfcV tags encode the exact tag type into their ID, so you could use
Tag.getId()
to get the ID and parse it according to the tag manufacturers' data sheets). Another approach is to read until the first IOException and infer the tag size from that information. You can later reconnect the tag to continue reading/writing. However, keep in mind that any other interruptions in communication (e.g. the user not properly scanning the tag) may also lead to IOExceptions and may consequently falsify your estimated tag size. - The block index parameter of the ISO/IEC 15693 read/write single block commands is in blocks and not in bytes.