Capturing NFC intents in a class library

Hi folks,

I'm a C#/Windows developer porting an NFC/JavaCard library to Xamarin/Android and I'm stuck on the Activity/Intent concept as it applies to Android.NFC.

In Windows, I have an NFC library that is de-coupled from the UI and is responsible for interrogating the NFC reader, raising events (CardDetected, etc) and then allowing the application to communicate with the Javacard afterwards. The calling application has nothing to do with NFC directly.

In Android, it seems that you need to have an Activity that listens for particular intents (i.e. ActionTechDiscovered). However an Activity seems to be inherently a UI concept used by Android to activate applications/screens in response to events.
I have the goal of still keeping the NFC library/interface completely separate from the UI, so how can I capture the same Intents in a class library that doesn't subclass Activity? Or do I have to just make a fake Activity implementation, in which case how do I then connect that to the Intent dispatch system?

I would really appreciate any guidance on this. Thanks!

Sign In or Register to comment.