getPackageManager().hasSystemFeature(NFC_SERVICE) 在三星 S5 中不工作

getPackageManager().hasSystemFeature(NFC_SERVICE) Not Working in Samsung S5

出于某种原因,getPackageManager().hasSystemFeature(NFC_SERVICE) 在 SamSung S5 中返回 null,即使我启用了 NFC,如下面的屏幕截图所示。

这里是我用来测试 NFC 服务是否可用的代码,但第一次测试失败

//check for the existence of
    // NFC adapter and beaming capability

    if (!getPackageManager().hasSystemFeature(NFC_SERVICE)){
        //this device is not equipped with NFC
        makeToast("This device does not have NFC hardware.");
        return;
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        // Android Beam feature is not supported.
        makeToast("Android Beam is not supported in this device");
        return;

    }

    // Check whether NFC is enabled on device
    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);

    if (!mNfcAdapter.isEnabled()){
        makeToast("Please enable NFC");
    }

    if(!mNfcAdapter.isNdefPushEnabled()) {
        // Android Beam is disabled, show the settings UI
        // to enable Android Beam
        makeToast("Please enable Android Beam.");
        startActivity(new Intent(Settings.ACTION_NFCSHARING_SETTINGS));
        return;
    }

有什么我应该做的不同的事情吗?

NFC_SERVICE is not a valid value to pass to hasSystemFeature(). Use FEATURE_NFC.