I have a similar case, and I think I know why it happens, even if the
API is not ideal for handling it:
If could be that your tag already has data written to it and that data
is locked or write-protected.
This happens in a tag I have that is a 1K tag, but I cannot write a
small Ndef to it.
I suspect that the size reported is the total size of the tag, not the
size of the writable space that is left after some data has been
written and then write-protected or locked.
I cannot find any way to confirm that theory in the code, and so as
(like you) I test almost everything else before trying the write, I
just surround my write with a Try/catch and assume the exception is
due to this reason.
The IOException returned on this error has no info related to the
cause.
So far, my only enhancement request to the Android team on the NFC API
would be to greatly enhance the IOExceptions returned in all the NFC
methods to give more information about the cause of the exception.
("Not enough space", "Write protected", etc).
If you find anything else that can help deal with this case, then
please post here and I will do the same.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en