Just read an NFC tag

后端 未结 2 1204
梦谈多话
梦谈多话 2021-02-11 00:38

I am developing an app that will use NFC tags for identification. All examples I find however, are about starting an app when a certain card is read. I tried looking for an exam

2条回答
  •  佛祖请我去吃肉
    2021-02-11 01:18

    If you want that the user first starts your app and only then scans an NFC card, I would recommend using NFC foreground dispatch. In that way, your Activity does not need to have any intent filters in the manifest (and thus will never be called by accident when the user scans another NFC card). With foreground dispatch enabled, your Activity can receive all NFC intents directly (without any app chooser pop-ups) and decide what to do with it (e.g. pass it on to another Activity).

提交回复
热议问题