I found some recent posts here about reading NFC Tags with Android. The conclusion that I got is that to performing an NFC read action triggers a separated intent.
What I want to achieve is that only my current activity is reading the NDEF message from a NFC tag in text/plain format.
So first question: Is it neccessary to list the intent-filter in my manifest?
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
I think this is not neccessary since I do not want to launch my app via NFC tag event, right?
Second question: How do I keep my NFC reading logic/functions related to my app/activity?
After
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />
I go to my current Activity and initialize the NFC Adapter onCreate:
mNfcAdapter = NfcAdapter.getDefaultAdapter(this)
What would be the next step to read the nfc tag NDEF message? Found something related with intent in dispatch foreground:
@Override
protected void onNewIntent(Intent intent) {
handleIntent(intent);
}
Would be nice if someone has an idea/example (Kotlin) how just to read a NFC tag from the activity without stuff like launching/beaming NFC actions.
In iOS e.g. there is a simple NFC session when needed in a VC.