Shubham Kumar Pandey
Shubham Kumar Pandey

Reputation: 31

How to detect NFC Enable/disable from device settings in Android/Flutter

I am creating an App for NFC HCE in Flutter. I want to notify the user when NFC is disabled from device settings.

I have tried platform channel to detect this, but when I turn off NFC from settings, then it claims that NFC is not supported, even when my device does have NFC.

My methods:

 private fun Context.isNfcAvailable(): Boolean {
        return NfcAdapter.getDefaultAdapter(this) != null
    }
 private fun Context.isNfcEnabled(): Boolean {
        val nfcAdapter = NfcAdapter.getDefaultAdapter(this)
        return nfcAdapter?.isEnabled ?: false
    }

Upvotes: 0

Views: 245

Answers (0)

Related Questions