checking internet connection [Solved]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

checking internet connection [Solved]

Post by Jellobus » Tue Jan 12, 2016 4:14 pm

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
Last edited by Jellobus on Wed Jan 13, 2016 6:18 am, edited 1 time in total.

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: checking internet connection

Post by LCNeil » Tue Jan 12, 2016 4:26 pm

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
--

Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

Re: checking internet connection

Post by Jellobus » Tue Jan 12, 2016 4:31 pm

Hi Neil,

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

Cheers,

Louis

trevix
Posts: 1079
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: checking internet connection [Solved]

Post by trevix » Fri Feb 07, 2020 10:10 am

On Android this is locking the App up to 30 seconds...
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: checking internet connection [Solved]

Post by bogs » Fri Feb 07, 2020 10:39 am

Hehe Trevix, I just answered in your thread on the topic, hopefully helpfully.
Image

Post Reply