The intent-filter and meta-data tags should go into the activity tag of the Main Activity. starting an app) I am asking whether the support is there by default, I know I could build my own app to listen for NFC events and handle them.
#Nfc reader app android android#
The uses-permission and uses-feature tags should belong to the manifest tag. On an Android device equipped with NFC reader hardware, is there any in-built support to use the NFC tag contents to fire off an intent (e.g. In this case, we have to use a different technique called NFC Foreground dispatch. To enable NFC on your android device, go to settings -> More -> and enable it. If our app is running in the foreground, it won’t be notified, if move our smartphone near an NFC tag.
Android NFC – Foreground Dispatchįiltering with intents works if our app is not in a foreground. We can, moreover, use other types of filters like android:scheme to filter using the protocol or using a string pattern. We can filter using several mime types not only text/pain. In other words when an NFC tag (NDEF format) is discovered and it has a mime type text/plain then our app will be started. Remember to choose your own package name. It is important to select a minimum SDK version of level 10, because NFC is only supported after Android 2.3.3.
We can use different types of filter, in this example (at line 8) we used the mime type. We start with a new project and a blank activity. To do it, we register the filter in the Manifest.xml: Īt line 6 we register our app so that it can be notified with ACTION_NDEF_DISCOVERED. As said, our goal is being notified when the smartphone is near a NFC tag and, if we have only this app installed and capable to handle this NFC tag, we want that the app starts immediately. We focus our attention on ACTION_NDEF_DISCOVERED, that has the highest level of priority.