I want to remove the warning which is showing in the code below m version.I had use below code which is working good but still want to remove the warning which is showing in line ConnectivityManager.TYPE_WIFI.Can below warning be removed which is also showing in kotlin compiler ??
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cm?.run {
cm.getNetworkCapabilities(cm.activeNetwork)?.run {
if (hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
return true
} else if (hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
return true
}
}
}
} else {
cm?.run {
cm.activeNetworkInfo?.run {
if (type == ConnectivityManager.TYPE_WIFI) {
return true
} else if (type == ConnectivityManager.TYPE_MOBILE) {
return true
}
}
}
}
Warning :- 'getter for type: Int' is deprecated.