How do I disable a function when and old android API

Asked

Viewed 41 times

0

I have the function View.OnScrollChangeListener which has been deployed to API 23 only. In the previous API example of Kitkat API 19. This function does not work. Like I do in my code oncreate when calling the function it check API to run?

1 answer

3


You should check which API the application user uses

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
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.