On Android 10, my NFC Logic works as expected and on Android 13 it does not work at all.
I tried to google the Solution, but the people are mostly using “nfcAdapter.enableForegroundDispatch” which may work if the App is opened, but not if the App is closed or never opened once.
The Android Doc for NFC does also not help: NFC Basics | Connectivity | Android Developers
I also experimented with granting different runtime Permissions to see if that might be the issue, but to no avail.
Android Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
...
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
Activity onCreate (Android 13 never reaches the Activity, Android 10 does):
super.onCreate(savedInstanceState)
System.err.println("Activity >> onCreate")
intent?.parcelable<Tag>(NfcAdapter.EXTRA_TAG)?.let { tag ->
// perform awesome logic
}
Does anyone have a Solution?