Check programmatically if device has NFC reader

giozh picture giozh · May 9, 2014 · Viewed 10.3k times · Source

Is there a way to check at run time whether a device has an NFC reader? My app uses NFC to perform a task, but if no reader is present, it can perform the same task by using a button.

Answer

Sainath Patwary karnate picture Sainath Patwary karnate · May 9, 2014

Hope This works for you

NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
NfcAdapter adapter = manager.getDefaultAdapter();
if (adapter != null && adapter.isEnabled()) {

    //Yes NFC available 
}else if(adapter != null && !adapter.isEnabled()){

   //NFC is not enabled.Need to enable by the user.
}else{
   //NFC is not supported
}