Question

I just finished my android app that have 1 activity, wherein it displays the data on the nfc tag, my problem is that whenever I tap nfc tag, the app opens/launch even if it is not open or running in the background. How can I prevent this from happening?

I want my app to react when it is open, thanks

Was it helpful?

Solution

If you don't want your activity to automatically start upon scanning a tag, simply don't register NFC related intent filters in your app's manifest.

But what if...

  1. ... you did not register any NFC related intent filters in the manifest but instead stored an Android Application Record (AAR) on the NFC tag. In this case your only option is to not use AARs.

  2. ... you now can't display the tag's data in your activity, because you do not receive any intent upon scanning an NFC tag. In this case, you should have registered for the NFC foreground dispatch system instead of registering an NFC intent filter in your app's manifest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top