Read the NFC tag regularly

I need to read the TAG TAG that is periodically fixed on the back of the phone. The problem is that android will only launch NFC when the TAG is first detected. I think either of these two possibilities could solve the problem, but I don't know if android resolves either of them

1- Force Android reads NFC TAG, but I don't know if it is possible, if it is, it would be the best solution, in this case, how could I do it?

2- Turn on the NFC adapter, when it turns on it will trigger NFC detection and my activity will consume this intent, but I think it is impossible to enable / disable the NFC adapter programmatically without user interaction (I need it to be automatic, opening settings WIFI is not possible)

Thank!!

+3


source to share


2 answers


Assuming your application is always in the foreground, I would keep the original Tag object in memory and query the tag periodically. If an exception is thrown when called connect()

, then the tag is out of range.



Then set the Tag object to null and listen for firing when the tag enters the phone field again.

0


source


Unable to use Android mode read / write mode when the screen is off or locked. In addition, there is an application that seems to be able to make this possible. Read this answer , it looks like a question.



0


source







All Articles