Start a new topic
Solved

Passing a value from Android to Java Script in Architect View

Hi


Normally I would pass a Value from my Android class to JavaScript with something like this:

WebView webView = (WebView) findViewById(R.id.webview);
webView.addJavascriptInterface(new WebAppInterface(this), "Android");

But this doesnt seem to work for the Architect view. So is there a way to pass a value from an Android Class to the Javascript running in the architect view?


Some example snipped would be nice


Thanks for your help in advance.


Hi Dennis


You need to use architectView.callJavaScript() to inject your values or host html on a server to pass params via url.


Maybe the examples provided below can also help you


http://www.wikitude.com/external/doc/documentation/latest/android/samples.html#communication-between-javascript-and-android-native-java


http://www.wikitude.com/external/doc/documentation/latest/android/retrievingpoidata.html#from-application-model-13


Thanks

Eva

 So I put

architectView.callJavascript("World.getDataFromNative("+testurl+");");

in the onPostCreate() and

getDataFromNative: function getDataFromNativeFn(data){
var url = data;
},
var htmlarea = new AR.HtmlDrawable({

uri: url
}, 0.4, {
viewportWidth: 900,
viewportHeight: 600,
backgroundColor: "#FFFFFF",
offsetX: -0.352,
offsetY: -0.464,
horizontalAnchor: AR.CONST.HORIZONTAL_ANCHOR.LEFT,
verticalAnchor: AR.CONST.VERTICAL_ANCHOR.BOTTOM,
clickThroughEnabled: true,
allowDocumentLocationChanges: false,
onDocumentLocationChanged: function onDocumentLocationChangedFn(uri) {
AR.context.openInBrowser(uri);
}
});

in my JavaScript.


But it doesnt seem to work. I dont know if I make a misstake with js or if I use the method to pass the value.



Please use WebView debugging to analyse the console.
I guess you just forgot to add the quotes, it should be


architectView.callJavascript("World.getDataFromNative('"+testurl+"');"); 


Best regards,
Andi



Login or Signup to post a comment