I want to be able to use the app on devices that run Android level 7, without this feature. If the device is API level 11 or newer, I want this feature to be available. Should I use @SuppressLint
or @TargetApi(HONEYCOMB)
and what's the difference?
Thanks!
Using TargetApi
, you tell the compiler that you are sure that this class/method/whatever is never ever called unless the API requirements are met.
That's what you want to do. But that also means that your must make sure that this class is never called under this level of API. You can do that by using
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Call that class
} else {
// Call another class
}