Quantcast
Channel: Questions in topic: "ping"
Viewing all articles
Browse latest Browse all 93

Detecting internet availability on Android

$
0
0
[Application.internetReachability][1] always returns [NetworkReachability.NotReachable][2] on my Android 2.1. Works as expected in Editor. I also tried using the [Ping][3] class to detect internet availability using the following C# code. ---------- IEnumerator CheckConnection() { const float timeout = 10f; float startTime = Time.timeSinceLevelLoad; Ping ping = new Ping("199.59.148.82"); while (true) { internetAvailableText = "Checking network..."; if (ping.isDone) { internetAvailableText = "Network available."; yield break; } if (Time.timeSinceLevelLoad - startTime > timeout) { internetAvailableText = "No network."; yield break; } yield return new WaitForEndOfFrame(); } } ---------- It always timed out. [WWW][4] class works as expected. Anyone had luck detecting internet access on Android? [1]: http://unity3d.com/support/documentation/ScriptReference/Application-internetReachability.html [2]: http://unity3d.com/support/documentation/ScriptReference/NetworkReachability.html [3]: http://unity3d.com/support/documentation/ScriptReference/Ping.html [4]: http://unity3d.com/support/documentation/ScriptReference/WWW.html

Viewing all articles
Browse latest Browse all 93

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>