The way I would probably do it, is to design a BaseActivity
class that enables NFC foreground dispatching. Whenever it receives an NFC intent in onNewIntent()
, it retrieves the ID of the tag and starts the relevant activity with an intent that contains the ID value.
I would then derive all my app Activities from this class. Whenever an NFC tag is scanned while the app is running, it will then receive the NFC intent automatically and dispatch it to the desired activity (which can show the tag ID).