Search code examples
androidandroid-studionfcmanifest

Create a check that the device supports NFC and it is enabled - Android


The condition which checks if the device supports NFC and it is enabled.


Solution

  • Call system service to detect this,sample codes:

    NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
    NfcAdapter adapter = manager.getDefaultAdapter();
    if (adapter != null && adapter.isEnabled()) {
       //support NFC
    }else{
       //doesn't support NFC
    }