Mit folgendem Code wollte ich die auf dem Android-Handy die Internet-Verbindung prüfen:
if environment()="mobile" then
put "http://www.google.com" into theURL
put URL theURL into connCheck
if connCheck is empty then
answer information "Derzeit keine Internetverbindung!" titled "Verbindungscheck"
else
answer information "OK!" titled "Verbindungscheck"
end if
end if
Das Handy hängt sich komplett auf (Samsung Galaxy Edge S7")
Auf dem Deskop funktionert es (mit environment "development")
Gibt es evtl. eine andere Möglichkeit?
keine Ahnung, warum die App dabei abkackt, aber versuche es mal hiermit.
Diese Funktion liefert FALSE/TRUE zurück, je nachdem ob eine Internetverbindung
steht oder nicht. Das tsNet External fragt hier nur den HEADER der Page ab, was
einen enormen Speedboost bei der Aktion bringt:
function checkURLAvailable tUrl
put tsNetHeadSync(tUrl, tSentHeaders, tResult, tBytes) into tHeaders
if (tResult < 400) then
return true
else
return false
end if
end checkURLAvailable
Also:
...
put "http://www.google.com" into theURL
if checkURLAvailable(tUrl) then
answer "Es besteht eine gültige Internetverbindung!"
else
answer "ZENSIERT!"
end if.
Danke für die rasche Antwort.
Ich bekomme einen Fehler bei der function: stack "Untitled 1": execution error at line 2 (Function: error in function handler) near "tsNetHeadSync", char 8
Leider der gleiche Fehler.
Hier nochmal der komplette Code:
on mouseUp pMouseButton
put "http://www.google.com" into tUrl
if checkURLAvailable(tUrl) then
answer "Es besteht eine gültige Internetverbindung!"
else
answer "ZENSIERT!"
end if
end mouseUp
function checkURLAvailable tUrl
put tsNetHeadSync(tUrl, tSentHeaders, tResult, tBytes) into tHeaders
if (tResult < 400) then
return true
else
return false
end if
end checkURLAvailable