https://kotlinlang.org logo
#android
Title
# android
t

tateisu

08/24/2019, 9:02 AM
Copy code
// (A) no warning
if(Build.VERSION.SDK_INT >= 26 ) {
	// using API 26+
}else if(Build.VERSION.SDK_INT >=22) {
	// using API 22+
}else{
	// using old API
}

// (B) waring raised.
// "Call required API level 26 (current min is 21): ..."
when{
	Build.VERSION.SDK_INT >= 26 ->{
		// using API 26+
	}
	Build.VERSION.SDK_INT >=22 ->{
		// using API 22+
	}
	else->{
		// using old API
	}
}
how to avoid warnings without extra if(Build.VERSION.SDK_INT >= ... ?
stackoverflow 1
🤔 1
this is not pure java issue, this is problem between android lint and kotlin "when".