1

I have an app which connects to smartcards, but when the display turns off, the app disconnects from the smartcard. Is it possible to turn the screen off but keep NFC active so that the app can send data to the smartcard and receive them?

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
schisskiss
  • 55
  • 4

2 Answers2

0

No that's (usually) not possible. On all (most?) Android devices, the NFC stack disables the reader functionality (and puts the NFC chipset into a low-power mode) when the screen turns off. The reason for this is pretty simple: You certainly do not want the NFC reader to drain your battery when you are not using your device (and a mobile device is typically not used when its screen is off). Hence, the only option is to keep the screen on while reading the tag. You can easily do this by adding the FLAG_KEEP_SCREEN_ON to your foreground activity.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
-1

This is because the application goes into background. You can try using a service in android to access the card when the application is in background. Be aware that this will consume more battery power.

You can refer this for better understanding

Aditya_Anand
  • 525
  • 7
  • 17
  • I have tried this but i dosen´t work because NFC uses a Foreground Dispatch. And the Dispatch can´t work i a service. – schisskiss Mar 08 '18 at 13:19