Start a new topic

How can I pass return values from a javascript function to android?

How can I pass return values from a javascript function to android?


Hello!

I'm using an architectView object to load a html file in my android project:

this.architectView.load("script.html");

Suppose that I want to obtain a value (ex. a string) from a javascript function in "script.html", how can I pass this value from javascript to android through my architectView object? If I had a webView it would be a lot easier because I could use the addJavascriptInterface() method.

Thank you in advance.

Sometimes events like a click in your AR-experience should cause a reaction in native Android, for instance: Launch another screen when clicking a place mark or image target.

You need to register a urlListener using architectView.registerUrlListener() in the Activity.

Any document.location changes toarchitectsdk:// will fire an event in your listener (e.g. document.location = architectsdk://YOUR-INFO). Listener is informed about the invoked url and can then react on to. 

Note: Missing urlListener registration will cause an HTTP-error when calling document.location = architectsdk://YOUR-INFO

 

Kind regards,
Andreas

Thanks so much Andreas. Now everything works!

Kind regards,

Gustav
Login or Signup to post a comment