Search code examples
androidnfc

Detect NFC tag while screen is locked


I want to be able to detect a simple NFC tag, and turn the phone on silence and then turn the silence off again, when the tag is removed. I have this all working when the phone is unlocked, but I need the app to work when the phone is locked. How would I go about getting this to work?


Solution

  • It's not possible to achieve this via your application alone. The core NFC service specifically forbids it. Users can either replace their NFC apk with one that does allow it, or install an Xposed module, but neither of those are something I would want to be instructing people to do, for security reasons.

    Another downside would be the excessive battery usage due to the phone having to poll for NFC events.