Search code examples
androidkotlinnfcndefhce

Getting android.intent.action.MAIN when approaching a NFC tag


I'm trying to get this app to run on my phone, but unfortunately when I debug the onNewIntent, I'm getting the wrong one (rather than Getting android.intent.action.NDEF_DISCOVERED I get android.intent.action.MAIN). This happens both if I try to use a second phone in HCE mode as well as if I approach a NFC tag. I don't have any idea, but I saw there's an issue related to this problem.

Do you know how to solve this? I already had a look at this old StackOverflow issue, but unfortunately I wasn't able to get the app to read the NDEF tag (for instance, I can read this same tag using NFC tools, so it must be something wrong with my code).


Solution

  • I was able to fix the problem and posted a working solution here: https://github.com/albertoZurini/NFC-Demo

    I'm still not sure, but it seems like a problem with the Android Studio project, I was able to find a working project on GitHub and I just replaced the code to make it working as I wanted.