I am working on an app which uses Android API 28, but I am having an issue with the app not always recognizing that the phone has internet access. However, other apps on the phone is working. The function I used to check the internet connection is:
fun checkInternetConnection(): Boolean { val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val networkInfo = connectivityManager.isDefaultNetworkActive return networkInfo }