I had a problem recently and I couldn't get an easy answer on the internet, I come to share my experience.
I needed to check the android version via code with all the ways I found on the internet were deprecated, here's the way I found current for this simple check
Resolução do problema foi
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
true
}
else{
false
}
You can check if your android version 33 or not by using this function: