Skip to content Skip to sidebar Skip to footer

Android @suppress Errors Vs @targetapi

Sometimes I case out code for certain versions of Android that may run my application. Eclipse with the latest Android tools still notices that my Manifest document allows lower ve

Solution 1:

@TargetApi(NN) says "Hey, Android! Yes, I know I am using something newer than what is allowed for in my android:minSdkVersion. That's OK, though, 'cause I am sure that I am using Build (or something) such that the newer code only runs on newer devices. Please pretend that my minSdkVersion is NN for the purposes of this (class|method)".

@SuppressLint, to address the same error, says "Hey, Android! Yes, I know I am using something newer than what is allowed for in my android:minSdkVersion. Quit complaining.".

Hence, given a choice of @TargetApi(NN) or @SuppressLint, go with @TargetApi(NN). There, if you start using something newer than NN -- and therefore your existing version-checking logic may be insufficient -- you will get yelled at again.

Post a Comment for "Android @suppress Errors Vs @targetapi"