android check internet connection

Black Bear answered on March 6, 2023 Popularity 8/10 Helpfulness 2/10

Contents


More Related Answers


android check internet connection

0
Tip Black Bear 1 GREPCC

fun isOnline(): Boolean {

return try {

val timeoutMs = 1500

val sock = Socket()

val sockaddr: SocketAddress = InetSocketAddress("8.8.8.8", 53)

sock.connect(sockaddr, timeoutMs)

sock.close()

true

} catch (e: Exception) {

false

}

Popularity 8/10 Helpfulness 2/10 Language kotlin
Source: Grepper
Link to this answer
Share Copy Link
Contributed on Mar 06 2023
Black Bear
0 Answers  Avg Quality 2/10


X

Sign in with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.