Mark
08/11/2021, 12:58 PMif
condition (at least 3 branches) where the checks are things like Build.VERSION.SDK_INT > 12
and then branch depends on such a later SDK level. How to suppress this warning?CLOVIS
08/11/2021, 1:22 PMMark
08/11/2021, 1:29 PMif (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
getVolumePathPre24(volumeId)
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
getVolumePathApi24Pre30(volumeId)
} else {
getVolumePathApi30(volumeId)
}
The called functions have the appropriate annotations like @RequiresApi(Build.VERSION_CODES.N)
CLOVIS
08/11/2021, 1:31 PMwhen
would give the exact same behavior since it's else-ifMark
08/11/2021, 1:32 PMAll warnings can be suppressed by clicking the right arrow on the warning list.Ah, thanks, I was wondering why sometimes I was seeing the suppress options, and other times not.
Why is that a false-positive?Because with
when
it won’t compile. The compiler doesn’t seem to figure out the API levels, unlike with if
Call requires API level 24 (current min is 23): getVolumePathApi24Pre30
CLOVIS
08/11/2021, 1:39 PMwhen
, it's just that when
is apparently broken. That code should be correct.ephemient
08/11/2021, 6:10 PMMark
08/12/2021, 2:30 AM