Reading a tag from a specific activity

好久不见. 提交于 2020-01-09 11:56:08

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/23290483/reading-a-tag-from-a-specific-activity

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!