CustomTabsCallback
class 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 |
|
|---|---|
const Int |
The activity is being displayed as a bottom-sheet at its initial height. |
const Int |
The activity is being displayed as a bottom-sheet at its maximized height. |
const Int |
The activity is being displayed over the whole window. |
const Int |
The activity is being displayed as a side-sheet at its initial width. |
const Int |
The activity is being displayed as a side-sheet at its maximized width. |
const Int |
The activity's layout state is unknown. |
const Int |
Sent when loading was aborted by a user action before it finishes like clicking on a link or refreshing the page. |
const Int |
Sent when the tab couldn't finish loading due to a failure. |
const Int |
Sent when the tab has finished loading a page. |
const Int |
Sent when the tab has started loading a page. |
const Int |
TAB_HIDDEN = 6Sent when the tab becomes hidden. |
const Int |
TAB_SHOWN = 5Sent when the tab becomes visible. |
Public constructors |
|---|
Public functions |
|
|---|---|
Unit |
extraCallback(callbackName: String, args: Bundle?)Unsupported callbacks that may be provided by the implementation. |
Bundle? |
extraCallbackWithResult(callbackName: String, args: Bundle?)The same as |
Unit |
onActivityLayout(Called when the Partial Custom Tab's layout has changed. |
Unit |
onActivityResized(Called when the tab is resized. |
Unit |
onMessageChannelReady(extras: Bundle?)Called when |
Unit |
onMinimized(extras: Bundle)Called when the Custom Tab is minimized by the user such that it covers a small part of the screen. |
Unit |
onNavigationEvent(navigationEvent: Int, extras: Bundle?)To be called when a navigation event happens. |
Unit |
onPostMessage(message: String, extras: Bundle?)Called when a tab controlled by this |
Unit |
onRelationshipValidationResult(Called when a relationship validation result is available. |
Unit |
onUnminimized(extras: Bundle)Called when the Custom Tab is unminimized by the user such that it returns back to its original state. |
Unit |
onWarmupCompleted(extras: Bundle)Called when the browser process finished warming up initiated by warmup. |
Constants
ACTIVITY_LAYOUT_STATE_BOTTOM_SHEET
const val ACTIVITY_LAYOUT_STATE_BOTTOM_SHEET = 1: Int
The activity is being displayed as a bottom-sheet at its initial height.
ACTIVITY_LAYOUT_STATE_BOTTOM_SHEET_MAXIMIZED
const val ACTIVITY_LAYOUT_STATE_BOTTOM_SHEET_MAXIMIZED = 2: Int
The activity is being displayed as a bottom-sheet at its maximized height.
ACTIVITY_LAYOUT_STATE_FULL_SCREEN
const val ACTIVITY_LAYOUT_STATE_FULL_SCREEN = 5: Int
The activity is being displayed over the whole window. This will be the case when a Partial Custom Tab bottom sheet or side sheet cannot be displayed due to minimum width restrictions (see EXTRA_INITIAL_ACTIVITY_WIDTH_PX) or browser limitations.
ACTIVITY_LAYOUT_STATE_SIDE_SHEET
const val ACTIVITY_LAYOUT_STATE_SIDE_SHEET = 3: Int
The activity is being displayed as a side-sheet at its initial width.
ACTIVITY_LAYOUT_STATE_SIDE_SHEET_MAXIMIZED
const val ACTIVITY_LAYOUT_STATE_SIDE_SHEET_MAXIMIZED = 4: Int
The activity is being displayed as a side-sheet at its maximized width.
ACTIVITY_LAYOUT_STATE_UNKNOWN
const val ACTIVITY_LAYOUT_STATE_UNKNOWN = 0: Int
The activity's layout state is unknown. This value communicates an error state, the fact that the state cannot be determined, or that the browser implementation does not provide support for this feature.
NAVIGATION_ABORTED
const val NAVIGATION_ABORTED = 4: Int
Sent when loading was aborted by a user action before it finishes like clicking on a link or refreshing the page.
NAVIGATION_FAILED
const val NAVIGATION_FAILED = 3: Int
Sent when the tab couldn't finish loading due to a failure.
NAVIGATION_FINISHED
const val NAVIGATION_FINISHED = 2: Int
Sent when the tab has finished loading a page.
NAVIGATION_STARTED
const val NAVIGATION_STARTED = 1: Int
Sent when the tab has started loading a page.
Public constructors
Public functions
extraCallback
fun extraCallback(callbackName: String, 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.
extraCallbackWithResult
fun extraCallbackWithResult(callbackName: String, 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, KEY_SUCCESS could be use to identify that callback was *successfully* handled. For example, when returning a message with result:
Bundle result = new Bundle(); result.putString("message", message); if (success) result.putBoolean(CustomTabsService#KEY_SUCCESS, true); return result;
Bundle result = extraCallbackWithResult(callbackName, args); if (result.getBoolean(CustomTabsService#KEY_SUCCESS)) { // callback was successfully handled }
onActivityLayout
fun onActivityLayout(
left: @Dimension(unit = 1) Int,
top: @Dimension(unit = 1) Int,
right: @Dimension(unit = 1) Int,
bottom: @Dimension(unit = 1) Int,
state: Int,
extras: Bundle
): Unit
Called when the Partial Custom Tab's layout has changed. This callback is not applicable to Custom Tabs that are not launched with EXTRA_INITIAL_ACTIVITY_WIDTH_PX or EXTRA_INITIAL_ACTIVITY_HEIGHT_PX set to their intent.
| Parameters | |
|---|---|
left: @Dimension(unit = 1) Int |
The new left coordinate of the Partial Custom Tab's window in pixels. |
top: @Dimension(unit = 1) Int |
The new top coordinate of the Partial Custom Tab's window in pixels. |
right: @Dimension(unit = 1) Int |
The new right coordinate of the Partial Custom Tab's window in pixels. |
bottom: @Dimension(unit = 1) Int |
The new bottom coordinate of the Partial Custom Tab's window in pixels. |
state: Int |
The type of Partial Custom Tab that is currently displayed on the screen. |
extras: Bundle |
Reserved for future use. |
onActivityResized
fun onActivityResized(
height: @Dimension(unit = 1) Int,
width: @Dimension(unit = 1) Int,
extras: Bundle
): Unit
Called when the tab is resized.
onMessageChannelReady
fun onMessageChannelReady(extras: Bundle?): Unit
Called when CustomTabsSession has requested a postMessage channel through requestPostMessageChannel and the channel is ready for sending and receiving messages on both ends.
| Parameters | |
|---|---|
extras: Bundle? |
Reserved for future use. |
onMinimized
fun onMinimized(extras: Bundle): Unit
Called when the Custom Tab is minimized by the user such that it covers a small part of the screen.
| Parameters | |
|---|---|
extras: Bundle |
Reserved for future use. |
onNavigationEvent
fun onNavigationEvent(navigationEvent: Int, extras: Bundle?): Unit
To be called when a navigation event happens.
onPostMessage
fun onPostMessage(message: String, 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.
onRelationshipValidationResult
fun onRelationshipValidationResult(
@CustomTabsService.Relation relation: Int,
requestedOrigin: Uri,
result: Boolean,
extras: Bundle?
): Unit
Called when a relationship validation result is available.
| Parameters | |
|---|---|
@CustomTabsService.Relation relation: Int |
Relation for which the result is available. Value previously passed to |
requestedOrigin: Uri |
Origin requested. Value previously passed to |
result: Boolean |
Whether the relation was validated. |
extras: Bundle? |
Reserved for future use. |
onUnminimized
fun onUnminimized(extras: Bundle): Unit
Called when the Custom Tab is unminimized by the user such that it returns back to its original state.
| Parameters | |
|---|---|
extras: Bundle |
Reserved for future use. |
onWarmupCompleted
fun onWarmupCompleted(extras: Bundle): Unit
Called when the browser process finished warming up initiated by warmup.
| Parameters | |
|---|---|
extras: Bundle |
Reserved for future use. |