Equivalent of window.addEventListener - Android Webview

Viewed 870

In my javascript application, I use the below code to listen to the data that was sent from a javascript file loaded on the server using parent.postmessage.

 window.addEventListener('message', function (event) {
        var response = event.data;
        if (response != null) {
           //Did something
        }

    }, false);

Currently, in Android I'm using

 WebView myWebView = (WebView) findViewById(R.id.webview);
    myWebView.loadUrl(url);

The URL is the same where there is a javascript loaded that sends some data using parent.postmessage on a button click. How can I receive it in Android?

0 Answers
Related