Android Question How to make NFC TAG trigger application?

RomansUP

Member
Licensed User
Longtime User
Hi everyone!
I looked at the forum, but I can not figure out how to make sure to run the third-part application on triggering NFC tag. What I mean: - My main trigger program on B4A should work in background. After I put NFC card to smartphone Main Program must come up and begins run in foreground. Then it starts predefine third-part application (activity) and goes again in background mode. Whether there are clear recommendations, and even better the program code how to do this?
Thanks, Shurale
 
Try this:
Add the following code to the manifest editor:
Code: Copy
AddActivityText(Main,
<intent-filter>
    <actionandroid:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
    android:resource="@xml/nfc_tech_filter" />)
CreateResource(xml, nfc_tech_filter.xml,
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
  <tech-list>
  <tech>android.nfc.tech.NfcA</tech>
  </tech-list>
</resources>)
The activity should be started (resumed) when you scan a tag.
 
Last edited:
Upvote 0
Super, it works. Thank you Erel.
But I have cathed two errors in code you gave me.
Firs: in string meta-dataandroid:name system show me an error. I made correction like this: meta-data android:name
and second - There was an error in tag </meta>) I just put the end of block like this : />)

Is it right? Or code works now incorrectly?
Nevertheless now it is no any errors. And my program works as I need.
Thank you for help
 
Upvote 0
Back
Top