I am working on a debugging app where I am attempting to:
- detect any NFC type A card
- connecting to it with
IsoDep
upon TAG discovery - reading its content and authenticating with PIN code
I always seem to get a TagLostException
upon sending the first ADPU command regardless of its content (selecting master file for example) or the subsequent ones if and only if the card was present (within the phone's NFC field) prior to any call to nfcAdapter.enableReaderMode(...)
.
So this does not happen if the card is brought inside the phone's NFC field after calling nfcAdapter.enableReaderMode(...)
. In that case, I can read all the data and properly authenticate using a PIN code. In that scenario I have a 99% success rate.
I am working with samsung devices, mainly the XCover 7 for pro usages.
I wonder, is having the card always stuck at the phone back an improper way of using NFC? Could that mean the phone already detected the card and won't allow further connection thus causing that exception to be thrown ?
Also, I tried using a longer timeout (5 seconds) but to no avail.
I am working on a debugging app where I am attempting to:
- detect any NFC type A card
- connecting to it with
IsoDep
upon TAG discovery - reading its content and authenticating with PIN code
I always seem to get a TagLostException
upon sending the first ADPU command regardless of its content (selecting master file for example) or the subsequent ones if and only if the card was present (within the phone's NFC field) prior to any call to nfcAdapter.enableReaderMode(...)
.
So this does not happen if the card is brought inside the phone's NFC field after calling nfcAdapter.enableReaderMode(...)
. In that case, I can read all the data and properly authenticate using a PIN code. In that scenario I have a 99% success rate.
I am working with samsung devices, mainly the XCover 7 for pro usages.
I wonder, is having the card always stuck at the phone back an improper way of using NFC? Could that mean the phone already detected the card and won't allow further connection thus causing that exception to be thrown ?
Also, I tried using a longer timeout (5 seconds) but to no avail.
Share Improve this question asked Mar 24 at 18:37 MackovichMackovich 3,6136 gold badges40 silver badges81 bronze badges1 Answer
Reset to default 0Android's NFC Service is always running and detecting NFC Tags (when the NFC is turned on in settings).
Using any of the ways of programming with NFC is just telling the NFC Service where to send the details about any NFC Tag it detects (with some Android versions, API's and Tags it can re-poll the Tag when you register your interest in being sent Tag Data)
So yes the normal flow is to register your interest in being sent Tag Data with the NFC Service when your App starts and then any Tag presented to your Phone after this is then sent to your App.
It's not a normal usecase to have a Tag stuck to the back of the phone, the phone will have detected it as soon as the TAG was placed in range, even with no user installed NFC enable Apps.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744233687a4564374.html
评论列表(0条)