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

    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
    http://www.b4x.com/android/forum/threads/nfcforeground-library-nfc-foreground-dispatch-system.31141/
    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 :)
     
Loading...
  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