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

Ping make my android app crash if no internet connection

$
0
0
Hi, I am looking for a system which determine if internet is available when i launch my app. After searching on internet i have try many solution and on editor this one works : IEnumerator CheckConnectionToMasterServer() { Ping pingMasterServer = new Ping("74.125.224.72"); float startTime = Time.time; while (!pingMasterServer.isDone && Time.time < startTime + 5.0f) { yield return new WaitForSeconds(5.0f); } if(pingMasterServer.isDone && pingMasterServer.time > 2) { Debug.Log ("IntenetON" ); } if(pingMasterServer.isDone && pingMasterServer.time<=1) { Debug.Log ("IntenetOFF" ); } } When i build an apk for android there is no problem, ping works (cause i am connected to wifi). If i launch with no internet connection my app instantly crash I have try to comment the while and always wait 5 seconds to check the ping result and its still crashing... Anyone can solve this issue ? Thank you.

Viewing all articles
Browse latest Browse all 93

Trending Articles



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