オンラインかオフラインか
タイトルの意味のままです
kotlin.kt
private fun isOnline(): Boolean {
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo = connectivityManager.activeNetworkInfo
return networkInfo?.isConnected == true
}
オンラインならtrueオフラインならfalseが返ってきます