parent
e89b597de6
commit
6441c04bae
@ -0,0 +1,15 @@ |
||||
package net.pokeranalytics.android.util.extensions |
||||
|
||||
import android.content.Context |
||||
import android.net.ConnectivityManager |
||||
import android.net.NetworkCapabilities |
||||
|
||||
/*** |
||||
* Returns whether the network is available or not |
||||
*/ |
||||
fun Context.isNetworkAvailable(): Boolean { |
||||
val cm = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager |
||||
val capability = cm.getNetworkCapabilities(cm.activeNetwork) |
||||
return capability?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) ?: false |
||||
} |
||||
|
||||
Loading…
Reference in new issue