I am able to read and wirte in my NFC demo app but I need to check if the NFC option in setting menu is enabled or not . If its not enable I want to direct the user to the setting menu(I know how to do this) similar to NFC TagWriter by NXP.
In my application I am using the following SDK version
<uses-sdk android:minSdkVersion="7" />
<uses-sdk android:maxSdkVersion="16"/>
I am unable to check if the setting is enabled or not.
TNR gets it right, however also note that from Android version 16, there is a more specific settings action for NFC:
protected void startNfcSettingsActivity() {
if (android.os.Build.VERSION.SDK_INT >= 16) {
startActivity(new Intent(android.provider.Settings.ACTION_NFC_SETTINGS));
} else {
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
}
}
Use the below code to get the NFCAdapter.
NfcAdapter nfcAdpt = NfcAdapter.getDefaultAdapter(this);
if(nfcAdpt!=null)
{
if(nfcAdpt.isEnabled())
{
//Nfc settings are enabled
}
else
{
//Nfc Settings are not enabled
}
}
If you want to navigate user to Settings of NFC then use below Code
Intent setnfc = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
startActivity(setnfc);
There is no NFC for API version 7. So change you manifest file as below
<uses-sdk android:minSdkVersion="10" />
<uses-sdk android:maxSdkVersion="16"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With