Hi
I opened developer tools on your website and the console showed this error:
Maybe this is why app inventor is not able to communicate?
This website can help you I think:
window.AppInventor.setWebViewString() & window.AppInventor.getWebViewString()
will only work inside an AI2 app, they will not work in a PC / Computer browser - where their use will break the script.
1 Like
@Oye_Lucky I got a great idea after I took a shower
First, try to use this code
<!DOCTYPE html>
<html>
<body onload="getLocation()">
<script>
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
window.AppInventor.setWebViewString("Geolocation is not supported.");
}
}
function showPosition(position) {
window.AppInventor.setWebViewString("Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude);
}
</script>
</body>
</html>
Second, use my edited project
test_webview_string.aia (2.1 KB)
If my solution helped you, please close this topic by clicking the solution button. Thank you
1 Like