Search code examples
androidnfc

How to check whether NFC is enabled or not in android?


How can i check whether NFC is enabled or not programmatically? Is there any way to enable the NFC on the device from my program? Please help me


Solution

  • NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
    NfcAdapter adapter = manager.getDefaultAdapter();
    if (adapter != null && adapter.isEnabled()) {
        // adapter exists and is enabled.
    }
    

    You cannot enable the NFC programmatically. The user has to do it manually through settings or hardware button.