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

Discussion in 'Code Snippets' started by DavideV, Jan 25, 2015.

  1. DavideV

    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:
    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


    Attached Files:

    Last edited: Jan 31, 2015
    KZero, raphaelcno, joop and 4 others like this.
  2. DonManfred

    DonManfred Expert Licensed User

    Nice. It´s working fine here. Thank you for sharing...
    DavideV likes this.
  3. raphaelcno

    raphaelcno Active Member Licensed User

    It is also possible to use the NfcForeground library
    which contains following methods:
    - NfcExists
    - NfcEnabled
    DavideV likes this.
  4. DavideV

    DavideV Active Member Licensed User

    hi Raphaelcno,thank you for pointing me to your lib, i haven't seen it before :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice