Start a new topic

How works ArchitectUrlListener ?

How works ArchitectUrlListener ?


Hi all,

I have a little question about "ArchitectUrlListener" and "architectsdk://...".

In fact, I don't understand how can I pass data between js and java. Actually, on my drawable, I activate "updateRate:AR.HtmlDrawable.UPDATE_RATE.HIGH" and

"clickThroughEnabled: true", so I can detect click into HTMLDrawables, it works, but I don't know how fire "urlWasInvoked" method in java.

 

I try "document.location = 'architectsdk://...' " but it nothing happen ..

 

Where I had wrong ?

 

Thanks

Thibault Morelle

Hi !

Be sure you registered the interface to the architectView. Example for Android :

architectView.registerUrlListener(new ArchitectUrlListener() {
@Override
public boolean urlWasInvoked(String arg0) {
...your code here...
return false;
}});

 

For the rest it seems true, just call "document.location = ..." works for me.

Hi, 

Thanks for your answer.

Yes, I call this code inside the AR Activity.

Do you think this problem may be due to the HTMLDrawable ? In fact, I call "document.location" inside the HTML Drawable ;)

 

Thibault Morelle

that's exactly the problem. However there is a quite simple solution. A HtmlDrawable has a trigger called onDocumentLocationChanged that is executed whenver a document.location change is detected.

To quickly give you some idea, this should be the only changes to make it work:

new AR.HtmlDrawabel(..., {..
onDocumentLocationChanged: function onDLCfn(uri) {
if (/*uri starts with architectsdk://*/) {
document.location = uri;
}
}


 

Oh Thanks,

It works great =D 
Login or Signup to post a comment