activeNetworkInfo.type is deprecated in API level 28
UPDATE The connectivityManager.activeNetworkInfo is also deprecated in API level 29 Now we need to use ConnectivityManager.NetworkCallback API or ConnectivityManager#getNetworkCapabilities or ConnectivityManager#getLinkProperties SAMPLE CODE USING ConnectivityManager#getNetworkCapabilities private fun isInternetAvailable(context: Context): Boolean { var result = false val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { val networkCapabilities = connectivityManager.activeNetwork ?: return false val actNw … Read more