Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device can communicate using Near-Field Communications (NFC).
Constant Value: "android.hardware.nfc"
Here are some examples of Android Phones with NFC.
1. Get a PackageManager Instance named myPackageManager.
- Professional NFC Application Development for Android by Vedat CoskunConstant Value: "android.hardware.nfc"
Here are some examples of Android Phones with NFC.
1. Get a PackageManager Instance named myPackageManager.
2. Create a Boolean Variable named bolNFCSupported.
3. Set the Minimum and Target SDK version to 9 or greater.
4. In the onCreate method, add the below code. This will return the NFC ability to a boolean named bolNFCSupported. It will then display a toast displaying the NFC ability of the device to the user.
bolNFCSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC);
if (bolNFCSupported) {
Toast.makeText(this, "Device has NFC capability. Yay!", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No NFC capability!", Toast.LENGTH_LONG).show();
}
5. Compile and run!
Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_NFC
Other Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_NFC