-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from GuoXiCheng/dev-c
update
- Loading branch information
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.android.skip.util | ||
|
||
import android.content.Context | ||
import android.net.ConnectivityManager | ||
import android.net.NetworkCapabilities | ||
import android.os.Build | ||
|
||
|
||
object NetworkUtil { | ||
fun isNetworkConnected(context: Context): Boolean { | ||
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | ||
val network = cm.activeNetwork ?: return false | ||
val capabilities = cm.getNetworkCapabilities(network) ?: return false | ||
return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters