No, your application cannot check which mode is currently turned on. The fact is that, by default, an Android device will periodically check all three modes (in fact, itβs a bit more complicated: these three modes themselves are divided into several parts, each survey is using a certain technology). Thus, while the screen is on, you can expect the Android device to cycle between listening to other readers and polling for various types of tag technologies and peer devices. In this case, regardless of whether you are registered to send a message in ad-hoc mode, the application is registered for HCE, or your application is registered for NFC detection purposes. Even if you disable Android Beam in the settings, the device will remain for polling for peer-to-peer mode.
Only if you explicitly disable card and P2P emulation using the reader mode API (available on Android 4.4+), your application can only control whether the reader / writer mode is active (and it can even control which tag technologies should be polled).
So, your application can find out what modes it turned on, and can make some assumptions, for example.
- If the screen is on and the read / write mode has not been explicitly forced using the read mode API, all three modes can be active.
- If the screen is off, only the card emulation mode can be active (although it depends on the device and HCE is usually not available).
Michael Roland
source share