12

I try to edit some code. According to the developer note, it's a part of app in android jelly bean version. But i found a piece of code that confusing me. What does this code mean? What's happened if we don't use this or deleting this piece of code:

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
pavel
  • 24,015
  • 8
  • 38
  • 57
umamlearn
  • 171
  • 1
  • 1
  • 7

2 Answers2

31

It's an annotation that tells the Android Lint tool that the following class or method is targeting a particular API level regardless of what is specified as the min SDK level in manifest.

Lint produces errors and warnings when you're using new functionality that is not available in the target API level. If you know what you're doing and have other mechanisms to prevent the code being run on older API levels, you can use this to suppress the lint errors and warnings.

If you remove the annotation, lint uses the manifest min SDK API level setting instead when checking the code.

http://developer.android.com/reference/android/annotation/TargetApi.html

laalto
  • 137,703
  • 64
  • 254
  • 280
0

This is a Java annotation made for android:

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)

It tells the lint tool, that the following class / method should only be executed if user is using the application under Honeycomb.

SuppressWarnings
  • 3,855
  • 4
  • 22
  • 33