RequiresApi vs TargetApi android annotations

前端 未结 5 1427
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 09:48

Whats the difference between RequiresApi and TargetApi?

Sample in kotlin:

@RequiresApi(api = Build.VERSION_CODES.M)
@Target         


        
5条回答
  •  隐瞒了意图╮
    2020-12-02 10:12

    @RequiresApi - Denotes that the annotated element should only be called on the given API level or higher.

    @TargetApi - Indicates that Lint should treat this type as targeting a given API level, no matter what the project target is.

提交回复
热议问题