How NFC technology requests work
mainUsing the library follows a 4-step lifecycle:
- Initialize: Call
NfcManager.start()to prepare the manager. - Request Technology: Use
NfcManager.requestTechnology(NfcTech.<TYPE>)to tell the system which specific NFC technology you want to listen for (e.g.,NfcTech.Ndef). - Access Handler: Once the technology is requested, access the corresponding handler via the
NfcManagerobject (e.g.,NfcManager.ndefHandler). Use this handler to call specific methods likegetNdefMessage(). - Cleanup: Always call
NfcManager.cancelTechnologyRequest()in afinallyblock to stop scanning and release resources.