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

Santhosh picture Santhosh · Oct 1, 2011 · Viewed 28.7k times · Source

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

Answer

Ronnie picture Ronnie · Oct 1, 2011
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.