Hi - there is this method `Duration.toMinutesPart(...
# getting-started
m
Hi - there is this method
Duration.toMinutesPart()
in
java.time.Duration
which is only available at API level 31+. My app needs to use 29 as min sdk (as I unfortunately have to support devices with this level). How can I write an own extension method, that will be used when using min sdk 29, but gets replaced by the native implementation at level 31+?
l
Check
Build.VERSION.SDK_INT >= 31
and act accordingly. That's what classes like
ActivityCompat
,
ContextCompat
are so on are doing. https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:core/cor[…]ndroidx/core/content/ContextCompat.java;l=582?q=ContextCompat
🙏 1