CustomTabsCallback
open class CustomTabsCallback
kotlin.Any | |
↳ | androidx.browser.customtabs.CustomTabsCallback |
A callback class for custom tabs client to get messages regarding events in their custom tabs. In the implementation, all callbacks are sent to the UI thread for the client.
Summary
Constants | |
---|---|
static Int |
Sent when loading was aborted by a user action before it finishes like clicking on a link or refreshing the page. |
static Int |
Sent when the tab couldn't finish loading due to a failure. |
static Int |
Sent when the tab has finished loading a page. |
static Int |
Sent when the tab has started loading a page. |
static Int |
Sent when the tab becomes hidden. |
static Int |
Sent when the tab becomes visible. |
Public constructors | |
---|---|
<init>() A callback class for custom tabs client to get messages regarding events in their custom tabs. |
Public methods | |
---|---|
open Unit |
extraCallback(@NonNull callbackName: String, @Nullable args: Bundle?) Unsupported callbacks that may be provided by the implementation. |
open Bundle? |
extraCallbackWithResult(@NonNull callbackName: String, @Nullable args: Bundle?) The same as |
open Unit |
onMessageChannelReady(@Nullable extras: Bundle?) Called when |
open Unit |
onNavigationEvent(: Int, @Nullable : Bundle?) To be called when a navigation event happens. |
open Unit |
onPostMessage(@NonNull message: String, @Nullable extras: Bundle?) Called when a tab controlled by this |
open Unit |
onRelationshipValidationResult(relation: Int, @NonNull requestedOrigin: Uri, result: Boolean, @Nullable extras: Bundle?) Called when a relationship validation result is available. |
Constants
NAVIGATION_ABORTED
static val NAVIGATION_ABORTED: Int
Sent when loading was aborted by a user action before it finishes like clicking on a link or refreshing the page.
Value: 4
NAVIGATION_FAILED
static val NAVIGATION_FAILED: Int
Sent when the tab couldn't finish loading due to a failure.
Value: 3
NAVIGATION_FINISHED
static val NAVIGATION_FINISHED: Int
Sent when the tab has finished loading a page.
Value: 2
NAVIGATION_STARTED
static val NAVIGATION_STARTED: Int
Sent when the tab has started loading a page.
Value: 1
Public constructors
<init>
CustomTabsCallback()
A callback class for custom tabs client to get messages regarding events in their custom tabs. In the implementation, all callbacks are sent to the UI thread for the client.
Public methods
extraCallback
open fun extraCallback(
@NonNull callbackName: String,
@Nullable args: Bundle?
): Unit
Unsupported callbacks that may be provided by the implementation.
Note:Clients should never rely on this callback to be called and/or to have a defined behavior, as it is entirely implementation-defined and not supported.
This can be used by implementations to add extra callbacks, for testing or experimental purposes.
Parameters | |
---|---|
callbackName |
String: Name of the extra callback. |
args |
Bundle?: Arguments for the callback |
extraCallbackWithResult
@Nullable open fun extraCallbackWithResult(
@NonNull callbackName: String,
@Nullable args: Bundle?
): Bundle?
The same as extraCallback
, except that this method allows the custom tabs provider to return a result. A return value of null
will be used to signify that the client does not know how to handle the callback. As optional best practices, CustomTabsService#KEY_SUCCESS
could be use to identify that callback was *successfully* handled. For example, when returning a message with result:
<code> Bundle result = new Bundle(); result.putString("message", message); if (success) result.putBoolean(CustomTabsService#KEY_SUCCESS, true); return result; </code>The caller side:
<code> Bundle result = extraCallbackWithResult(callbackName, args); if (result.getBoolean(CustomTabsService#KEY_SUCCESS)) { // callback was successfully handled } </code>
onMessageChannelReady
open fun onMessageChannelReady(@Nullable extras: Bundle?): Unit
Called when CustomTabsSession
has requested a postMessage channel through CustomTabsService#requestPostMessageChannel( * CustomTabsSessionToken, android.net.Uri)
and the channel is ready for sending and receiving messages on both ends.
Parameters | |
---|---|
extras |
Bundle?: Reserved for future use. |
onNavigationEvent
open fun onNavigationEvent(
: Int,
@Nullable : Bundle?
): Unit
To be called when a navigation event happens.
Parameters | |
---|---|
navigationEvent |
Int: The code corresponding to the navigation event. |
extras |
Bundle?: Reserved for future use. |
onPostMessage
open fun onPostMessage(
@NonNull message: String,
@Nullable extras: Bundle?
): Unit
Called when a tab controlled by this CustomTabsSession
has sent a postMessage. If postMessage() is called from a single thread, then the messages will be posted in the same order. When received on the client side, it is the client's responsibility to preserve the ordering further.
Parameters | |
---|---|
message |
String: The message sent. |
extras |
Bundle?: Reserved for future use. |
onRelationshipValidationResult
open fun onRelationshipValidationResult(
relation: Int,
@NonNull requestedOrigin: Uri,
result: Boolean,
@Nullable extras: Bundle?
): Unit
Called when a relationship validation result is available.
Parameters | |
---|---|
relation |
Int: Relation for which the result is available. Value previously passed to CustomTabsSession#validateRelationship(int, Uri, Bundle) . Must be one of the CustomTabsService#RELATION_* constants. |
requestedOrigin |
Uri: Origin requested. Value previously passed to CustomTabsSession#validateRelationship(int, Uri, Bundle) . |
result |
Boolean: Whether the relation was validated. |
extras |
Bundle?: Reserved for future use. |