Webview string not working

Hey all just wanted to ask that is webview string not working as yesterday while testing my appathon project it was working but not now it thought it might be a problem with my code so i made another project for testing can any one confirm

attatching the testing aia test_webview_string.aia (2.0 KB)

1 Like

@Oye_Lucky please change your topic category to MIT App Inventor Help
because the content of your topic does not fit the category.
And don't use the appathon category if your context is to ask for help.
Also please clarify what you expect, read this too :

How to ask a question (open new topic)

Nothing in your test aia project will produce a return from the webviewstring.

why ? the url has been set
https://location-latitude.000webhostapp.com/ the homeurl

read this
https://puravidaapps.com/snippets.php#2webviewstring

this the the code that i have hosted

<!DOCTYPE html>
<html>
<body>
<button id="buttonop" onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else { 
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude;
window.AppInventor.setWebViewString(position.coords.latitude )
}
</script>
</html>
1 Like

hey but the webview string was working properly yesterday

looks like you forgot to input the html code into the ai2 asset

not needed i hosted this code on 000webhost

https://location-latitude.000webhostapp.com/

okay i got it

1 Like

i think you should get the code from that website with this trick:

blocks (3)

not working could you try at your end

why @TIMAI2 could you please elaborate

I don't know much about JS but as i read here:

https://puravidaapps.com/snippets.php#2webviewstring

you have not written getWebViewString() in your HTML and JS code

so it does not return any webview string. Try this method.

see this this sets the webview string to my current latitude

and this code sets

lable 1 to webview strng

Just retested your code and it works. You either did not give location permission (location services not turned on ?) or you did not wait until the the location sensor on the device had got a fix, and could therefore return a value.

Regardless, as previously suggested, this method is no quicker than directly using the location component.

are you sure

already given the permission

waited for 5 minutes

its (location sensor) too slow, my code was returning the value within seconds yesterday dont know what happened today

@Oye_Lucky close this line :
window.AppInventor.setWebViewString(position.coords.latitude)
with ; on your code

1 Like

not working updated my site too