3
votes

I'm writing a kiosk-like micro-browser which opens specific pages based on payload of specific scanned RFID tags.

In order to both provide a method for reopening the app (the app is for public use) and handling all RFID scans, I'm trying to make my app handle all android.nfc.action.NDEF_DISCOVERED actions with a single instance of the main activity.

Currently, every time a new RFID tg is scanned, a new instance of my activity opens, whether or not there was one already open. Obviously, this is not ideal. Can a single instance of an activity handle all of these implicit intents?

I've already looked at using the singleTop attribute and flag, but I don't know of a way to set a flag for an implicit intent caused by an external system-generated intent, ie discovering an NFC tag.

this is my first time asking my own question here, so I'm sorry if that didn't make much sense.

1
I found this code which answers my question. I was missing a PendingIntent with which I could specify flags for android.nfc.action.NDEF_DISCOVERED. java2s.com/Code/Android/Core-Class/…medavox

1 Answers

1
votes

This link answered the question for me, as explained in the comment i made (before I could answer this myself).

http://www.java2s.com/Code/Android/Core-Class/AnexampleofhowtousetheNFCforegrounddispatchAPIs.htm

My problem was I didn't know of/use a PendingIntent, which seems to be some kind of archetype you can use to specify properties (namely the eponymous flags) to later types of Intents.