Android API level annotation for Android libraries

前端 未结 2 2061
情深已故
情深已故 2020-12-31 05:10

I am writing an Android library. The vast majority of the interface in the lbirary supports Android API level 10 or above. Some functionality, though, requires a higher API

2条回答
  •  醉酒成梦
    2020-12-31 05:37

    I have recently done this on a custom view class, which needed special constructor for some api levels.

    I have done it with the @TargetApi annotation.

    If a method is available only since api level 16:

    @TargetApi(16)
    public void someMethod () {}
    

    This should do the trick, including lint errors.

提交回复
热议问题