Page 1 of 1

checking internet connection [Solved]

Posted: Tue Jan 12, 2016 4:14 pm
by Jellobus
Hi all,

Is there efficient way to check internet connectivity on mobile? here is my script but I am not sure if there is better way to do. I hope there is something simpler.

Code: Select all

local sBrowserId

on openCard
   checkInternetConnection
end openCard

on checkInternetConnection
   mobileControlCreate "browser"
   put the result into sBrowserId
   mobileControlSet sBrowserId, "visible", "false"
   mobileControlSet sBrowserId, "url", "https://www.google.com"
   mobileControlSet sBrowserId, "rect", the rect of current card
end checkInternetConnection

on browserFinishedLoading pUrl
   mobileControlDelete sBrowserId
   go to card "start"
end browserFinishedLoading

on browserLoadFailed pUrl, pError
   mobileControlDelete sBrowserId
   answer "Can't load server."&cr &"Please check internet connection."
end browserLoadFailed
It'll be appreciated if anyone can advice in this regard.

Cheers,

Louis

Re: checking internet connection

Posted: Tue Jan 12, 2016 4:26 pm
by LCNeil
Hi Louis,

Something like the following should help out-

Code: Select all

command checkInternetConnection

put url "http://www.google.com" into tURL

if tURL is empty then
answer "It looks like you have no connection"
end if

end checkInternetConnection
Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--

Re: checking internet connection

Posted: Tue Jan 12, 2016 4:31 pm
by Jellobus
Hi Neil,

That's great. It works well. Thank you very much!

Cheers,

Louis

Re: checking internet connection [Solved]

Posted: Fri Feb 07, 2020 10:10 am
by trevix
On Android this is locking the App up to 30 seconds...

Re: checking internet connection [Solved]

Posted: Fri Feb 07, 2020 10:39 am
by bogs
Hehe Trevix, I just answered in your thread on the topic, hopefully helpfully.