Android Code Snippet Check if a device has NFC and it's status

DavideV

Active Member
Licensed User
Hi all, i'm working on an NFC app and i need to know if a device has NFC capabilities and if it's enabled or not.
The current nfc library doesn't have this function so i decided to write this piece of code and share it with you.

To do this i reused some pieces of useful code to get the BA.context from here:
http://www.b4x.com/android/forum/threads/problem-with-additionaljar-javaobject-and-context.48958/
all credits to his author.

The uploaded code is commented and self-explanatory, you need at least api 10 to compile this and NFC permission in manifest.
It uses javaobject and phone library

With this code you can:
-check if a device is NFC capable
-check if the NFC hardware is enabled or disabled
-Open the NFC settings screen

Bye
DavideV
 

Attachments

Last edited:

raphaelcno

Active Member
Licensed User
Hi all, i'm working on an NFC app and i need to know if a device has NFC capabilities and if it's enabled or not.
The current nfc library neither the other libs i found in the forum have this function so i decided to write this piece of code and share it with you.
With this code you can:
-check if a device is NFC capable
-check if the NFC hardware is enabled or disabled
-Open the NFC settings screen
It is also possible to use the NfcForeground library
http://www.b4x.com/android/forum/threads/nfcforeground-library-nfc-foreground-dispatch-system.31141/
which contains following methods:
- NfcExists
- NfcEnabled
 
Top