Jelly Bean has come out and they have some pretty nice features. My question is that I want to target as many devices as possible, but at the same time have an app that can if possible use all the features in the highest API level.
So say for example I have this
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16"/>
And I build my application on API 16. Is there a way to restrict certain parts of the code to say only run if you are running a device that is capable of running it? For example, If I want NFC, then only gingerbread devices and above can use the feature, else froyo down won't even see the feature.
Basically, you can use many of the new API introduced from Android 3.0 (for example, the Fragment engine), including the Android Support v4 as Referenced Library.
You can find some reference here:
http://developer.android.com/reference/android/support/v4/app/package-summary.html
and here:
http://developer.android.com/tools/extras/support-library.html
By the other hand, if you want use NFC feature for example, you can declare this use-feature:
<uses-feature android:name="android.hardware.nfc" android:required="true" />
or, if you want provide code alternative for devices with no support for this feature, you can do something like that:
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
//code for devices with NFC support
} else {
//code for others devices
}