Skip to main content

Android

Build an object to handle the postMessage call:

class SmartzerPostMessageHandler {
@JavascriptInterface
public boolean postMessage(final String json) {
// parse the json and then do some custom action here using the content of json.cta
return true; // here we return true if we handled the post.
}
}

Create a webview and attach the MessageHandler:

  WebSettings webSettings = view.getSettings();
webSettings.setJavaScriptEnabled(true);
view.addJavascriptInterface(
new SmartzerPostMessageHandler(), "smrtzrApp"
);
view.loadUrl("<your_player_url>");