Is @TargetApi annotation just for one Api level or above?

@TargetApi does not prevent any code from running, all it does is to remove lint errors.

You still need to add something along the lines of

if (Build.VERSION.SDK_INT > 7){
    //...
}

TargetApi annotation is just for lint tool purposes and has no outcome in runtime. If you use any API methods just available on 23 within your method and don't declare the TargetApi, you will just get some warnings indicating you're using API's not available in your minimum SDK version. It's your responsibility to call this method with coherence being aware of the API level it will be called from.

Tags:

Android