Start a new topic

Javascript and Java interaction

Javascript and Java interaction

Dear Wikitude support

I use wikitude javascript librarys in Android app.

When a target image is recognised apllication creates a button overlay. That done in javascript. Java sould capture when button is pressed. As I understood it should be done in ArchitectUrlListener, because in Wikitude's example it's done like that.

How to do that? Do I need to give an Id to that button? And it seems like invokedUri.getHost() returnes nothing.


Hi Wenhao,

you are right, you can achieve what you want by using the Architect.UrlListener.

To call the Architect.UrlListener from JavaScript use:

document.location = "architectsdk://yourHostName?id=button1";


You will need to use the first part of the string "architectsdk://" or the url listener won't pick up the call. If you want to convert the passed value into a Java url object the rest of the string value needs to conform to the standard url pattern. The first value will be the host name, parameters will be indicated by the question mark and so on.

To use this in your button override the onClick method and make the call:

World.myButton.onClick = function() {
document.location = "architectsdk://yourHostName?id=button1";


You don't necessarily need the id parameter you could also use one hostname per button.

I hope that helps, if you have any other questions feel free to ask.

Best regards,

Login or Signup to post a comment