call method another class
call method another class In Kotlin
AppUtility.kt
//class to objectobject 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
Post a Comment