Annotation Type RequiresApi


  • @Documented
    @Retention(SOURCE)
    @Target({TYPE,METHOD,CONSTRUCTOR,FIELD})
    public @interface RequiresApi
    Denotes that the annotated element should only be called on the given API level or higher.

    This is similar in purpose to the older @TargetApi annotation, but more clearly expresses that this is a requirement on the caller, rather than being used to "suppress" warnings within the method that exceed the minSdkVersion.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      int api
      The API level to require
      int value
      The API level to require.
    • Element Detail

      • value

        @IntRange(from=1L)
        int value
        The API level to require. Alias for api() which allows you to leave out the api= part.
        Default:
        1