call method another class

call method another class In Kotlin

AppUtility.kt
//class to object
object AppUtility {
    fun isConnectivityAvailable(context: Context): Boolean {
        val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
        val activeNetwork = connectivityManager.activeNetworkInfo        return activeNetwork != null && activeNetwork.isConnectedOrConnecting    }
}

EmptyActivity.kt

if(AppUtility.isConnectivityAvailable(this@EmptyActivity))

Comments

Popular posts from this blog