How do I disable a function when android android API

0

I have the View.OnScrollChangeListener function that was deployed only in API 23. In the previous API example of the KitKat API 19. This function does not work. How do I do in my code oncreate when calling the function it check API to execute?

    
asked by anonymous 01.11.2016 / 14:26

1 answer

3

You should check the API used by the application user

Example:

int currentapiVersion = android.os.Build.VERSION.SDK_INT;

if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){
    // faz algo do Lollipop em diante
} else{
    // faz algo do Lollipop para trás
}
    
01.11.2016 / 14:38