@SuppressLint ("Newapi") in Android code, we sometimes use the android:minsdkversion that we set in Androidmanifest
Version of the method, the compiler prompts for a warning when the workaround is to add @suppresslint ("Newapi") or @targetapi () to the method.
What's the difference between them, very simple,
@SuppressLint ("Newapi") block all new APIs in order to use the method reported by Android Lint error
@TargetApi () block only a new API to use the lint error of a method reported Android
For example, a method that uses the Api9 new method, and the android:minsdkversion=8 of the project settings,
At this point, add @suppresslint ("Newapi") and @targetapi (Build.version_codes) on the method. Gingerbread) All can, the above is the general situation.
And when you refer to a method in this method that api11 only joins, @TargetApi (Build.version_codes. Gingerbread) The method of annotating the error again,
and @suppresslint ("Newapi") will not error, this is the difference.
Of course, regardless of which annotation you use, the role is only to block Android lint errors, so in the method also to determine the version to do different operations, such as:
if (Build.VERSION.SDK_INT >= build.version_codes. Gingerbread) { // else {// Pre gingerbread // }
Android.annotation.SuppressLint