Android - Check for NFC Hardware Availability

public boolean checkNFCHardware() {
    NfcManager nfcManager = (NfcManager) getSystemService(Context.NFC_SERVICE);
    NfcAdapter nfcAdapter = nfcManager.getDefaultAdapter();
    if (nfcAdapter == null) {
        // Device not compatible for NFC support        return false;
    } else if (!nfcAdapter.isEnabled()) {
        // If NFC not enabled, application can request Settings UI allowing the user to toggle/enable NFC from        startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
        return false;
    } else {
        return true;
    }
}

Comments

Popular posts from this blog

Android - Using KeyStore to encrypt and decrypt the data

Stack and Queue

Java Reflection API