0

Im trying to create a library, but some methods will only work for API > 21.

How can I set the minimum api target for this method and show a warning?

like the TextureView for example:

I need to show this warning

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public CustomTextureView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    init(attrs);
}
Harshad
  • 1,344
  • 1
  • 10
  • 25
Isquierdo
  • 745
  • 1
  • 10
  • 29

1 Answers1

1
// Check if we're running on GingerBread or above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
    // do somthing 

// if not
} else {
    // do somthing
}
Suhas Bachewar
  • 1,230
  • 7
  • 21