Stay organized with collections
Save and categorize content based on your preferences.
WebMessage
open class WebMessage
The Java representation of the HTML5 PostMessage event. See https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces for definition of a MessageEvent in HTML5.
Summary
Public constructors |
Creates a WebMessage.
|
Creates a WebMessage.
|
Public methods |
open String! |
Returns the data of the message.
|
open Array<WebMessagePort!>? |
Returns the ports that are sent with the message, or null if no port is sent.
|
Public constructors
WebMessage
WebMessage(data: String!)
Creates a WebMessage.
Parameters |
data |
String!: the data of the message. |
Public methods
getData
open fun getData(): String!
Returns the data of the message.
getPorts
open fun getPorts(): Array<WebMessagePort!>?
Returns the ports that are sent with the message, or null
if no port is sent.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# WebMessage\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nWebMessage\n==========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/webkit/WebMessage \"View this page in Java\") \n\n```\nopen class WebMessage\n```\n\n|---|--------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.webkit.WebMessage](#) |\n\nThe Java representation of the HTML5 PostMessage event. See https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces for definition of a MessageEvent in HTML5.\n\nSummary\n-------\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [WebMessage](#WebMessage(kotlin.String))`(`data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Creates a WebMessage. |\n| [WebMessage](#WebMessage(kotlin.String,%20kotlin.Array))`(`data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `ports:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\u003c[WebMessagePort](/reference/kotlin/android/webkit/WebMessagePort)!\u003e!`)` Creates a WebMessage. |\n\n| Public methods ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getData](#getData())`()` Returns the data of the message. |\n| open [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\\\u003c[WebMessagePort](/reference/kotlin/android/webkit/WebMessagePort)!\\\u003e? | [getPorts](#getPorts())`()` Returns the ports that are sent with the message, or `null` if no port is sent. |\n\nPublic constructors\n-------------------\n\n### WebMessage\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nWebMessage(data: String!)\n```\n\nCreates a WebMessage.\n\n| Parameters ||\n|--------|-------------------------------------------------------------------------------------------------------------|\n| `data` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the data of the message. |\n\n### WebMessage\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nWebMessage(\n data: String!, \n ports: Array\u003cWebMessagePort!\u003e!)\n```\n\nCreates a WebMessage.\n\n| Parameters ||\n|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `data` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the data of the message. |\n| `ports` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\\\u003c[WebMessagePort](/reference/kotlin/android/webkit/WebMessagePort)!\\\u003e!: the ports that are sent with the message. |\n\nPublic methods\n--------------\n\n### getData\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getData(): String!\n```\n\nReturns the data of the message. \n\n### getPorts\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getPorts(): Array\u003cWebMessagePort!\u003e?\n```\n\nReturns the ports that are sent with the message, or `null` if no port is sent."]]