public interface

WebViewCompat.WebMessageListener

 androidx.webkit.WebViewCompat.WebMessageListener

Overview

This listener receives messages sent on the JavaScript object which was injected by WebViewCompat.addWebMessageListener(WebView, String, Set, WebViewCompat.WebMessageListener).

Summary

Methods
public voidonPostMessage(WebView view, WebMessageCompat message, Uri sourceOrigin, boolean isMainFrame, JavaScriptReplyProxy replyProxy)

Receives a message sent by a postMessage() on the injected JavaScript object.

Methods

public void onPostMessage(WebView view, WebMessageCompat message, Uri sourceOrigin, boolean isMainFrame, JavaScriptReplyProxy replyProxy)

Receives a message sent by a postMessage() on the injected JavaScript object.

Note that when the frame is file: or content: origin, the value of sourceOrigin is a string "null". However we highly recommend to not use file: or content: URLs, see WebViewAssetLoader for serving local content under http: or https: domain.

Parameters:

view: The containing the frame which sent this message.
message: The message from JavaScript.
sourceOrigin: The origin of the frame that the message is from.
isMainFrame: true If the message is from the main frame.
replyProxy: Used to reply back to the JavaScript object.