Reputation: 1
I am using below sample code to read NFC tag, but it is not reading tag multiple time(sometimes it's reading for 3 time, some time it is reading 6-7 time). In my application I need to read nfc tag continuously.
https://github.com/andijakl/NfcDemo
Upvotes: 0
Views: 2502
Reputation: 10222
NFC reading can be very picky about the exact placement of the NFC Tag.
Under ideal conditions the range is usually about 4cm Max when aligned with the phones antenna but miss alignment can reduce this range significantly.
Some smaller (non credit card Tags) have a smaller antenna and thus miss alignment and reduced range is more likely.
Also atmospheric and other conditions can reduce the range.
So reliable NFC reading requires the Tag to be in range long enough to be read and NFC reading data rates are not fast so with large amounts it requires more time in range.
So you might want to make sure you are correctly aligning the Tag with the antenna to get reliable NDEF reads. If the centre of the NFC antenna is not marked with the NFC logo then try approaching a Tag or simple field detector (https://www.youtube.com/watch?v=dTv4U5fotM0 ) from different direction to identify the edges of the field to estimate it's centre.
From the source code side the Demo looks correct for using the older NFC API and should read NDEF messages fine.
BUT
The older NFC API is extremely unreliable for use with NDEF writing or reading or writing non NDEF data, this is because it prompts the user poorly with it's detection sounds which you have no control of.
If you want to do anything other than simple NDEF reading I suggest that you use the new and better enableReaderMode
API example code for using the enableReaderMode API
Upvotes: 0