The Android system has a structured way to deal with the different tag types, technologies, and content. In this recipe, we will create a simple app that will allow us to visualize the implemented structure.
By performing the following steps, we are going to create an application that will allow us to see the triggered action when we tag different tags in our device:
MainActivity.javafile from the previously created
onNewIntentmethod, add the following lines of code:
String action = intent.getAction(); Toast.makeText(this, action, Toast.LENGTH_SHORT).show();
Open the NFC Simulator tool and simulate a few taps for different tag types and then see the results.
In the NFC Simulator tool, when tag names end with
_LOCKED, it means that the tags are formatted and have content on them; probably, an NDEF record. Therefore, the
NDEF_DISCOVEREDaction will be triggered. Unformatted tags will trigger the...