Search code examples
androidurlbrowsernfcrfid

How to disable opening browser with NFC while user uses my app?


I am working on reading RFID. When I use my app. The app detects the RFID and show the result in the app. But also the phone opens browser which is duplicate. And I don't need the browser one.

The browser opens up even if my app is not installed on the phone after detecting the RFID.

How can I block opening the browser but only works on my app?


Solution

  • The same issue was coming on my app also, it's a flutter app though (on Android). The key to the solution for my case was that the browser was only opening when my app was not actively scanning or having an active NFC session; which means if my app has requested the polling or is requesting the tag data (basically having an active NFC session), then the browser was not opening.

    So the solution is to wait (4 seconds in my case) before closing the session, after receiving data. Earlier what was happening was, as I get the data, I closed the session and then OS takes over the NFC scanning; and because the tag is still near the device, OS also detects it and opens the browser.