WebMessageCallbackCompat
abstract class WebMessageCallbackCompat
kotlin.Any | |
↳ | androidx.webkit.WebMessagePortCompat.WebMessageCallbackCompat |
The listener for handling MessagePort events. The message callback methods are called on the main thread. If the embedder application wants to receive the messages on a different thread, it can do this by passing a Handler in WebMessagePortCompat#setWebMessageCallback(Handler, WebMessageCallbackCompat)
. In the latter case, the application should be extra careful for thread safety since WebMessagePort methods should be called on main thread.
Summary
Public constructors | |
---|---|
<init>() The listener for handling MessagePort events. |
Public methods | |
---|---|
open Unit |
onMessage(@NonNull port: WebMessagePortCompat, @Nullable message: WebMessageCompat?) Message callback for receiving onMessage events. |
Public constructors
<init>
WebMessageCallbackCompat()
The listener for handling MessagePort events. The message callback methods are called on the main thread. If the embedder application wants to receive the messages on a different thread, it can do this by passing a Handler in WebMessagePortCompat#setWebMessageCallback(Handler, WebMessageCallbackCompat)
. In the latter case, the application should be extra careful for thread safety since WebMessagePort methods should be called on main thread.
Public methods
onMessage
open fun onMessage(
@NonNull port: WebMessagePortCompat,
@Nullable message: WebMessageCompat?
): Unit
Message callback for receiving onMessage events.
This method is called only if WebViewFeature#WEB_MESSAGE_CALLBACK_ON_MESSAGE
is supported. You can check whether that flag is supported using WebViewFeature#isFeatureSupported(String)
.
Parameters | |
---|---|
port |
WebMessagePortCompat: the WebMessagePort that the message is destined for |
message |
WebMessageCompat?: the message from the entangled port. |