NavigationListener


@WebNavigationClient.ExperimentalNavigationCallback
public interface NavigationListener


Page identification and lifecycle APIs.

This class provides callbacks to identify the different stages of navigation. For more information about the navigation lifecycle, please see the Life of a Navigation Presentation.

Note: These navigation callbacks only fire for navigations happening on the main frame.

Navigation lifecycle events:

Summary

Public methods

default void
onFirstContentfulPaint(@NonNull Page page, long loadTimeUs)

Called when the page achieves "First Contentful Paint".

default void

Called when a navigation completes.

default void

Called when a navigation is redirected.

default void

Called when a navigation starts, including same-document navigations.

default void

Called when any Page is evicted/destroyed.

default void

Called when the DOMContentLoaded event is fired for the current page.

default void

Called when the window.load event is fired for the current page.

Public methods

onFirstContentfulPaint

Added in 1.15.0-beta01
default void onFirstContentfulPaint(@NonNull Page page, long loadTimeUs)

Called when the page achieves "First Contentful Paint".

See First Contentful Paint (FCP) for a definition.

Parameters
@NonNull Page page

The Page for which the First Contentful Paint occurred.

long loadTimeUs

Navigation to First Contentful Paint load time in microseconds.

onNavigationCompleted

Added in 1.15.0-beta01
default void onNavigationCompleted(@NonNull Navigation navigation)

Called when a navigation completes.

The navigation might not have actually committed (e.g., results in 204/download/cancelled).

Parameters
@NonNull Navigation navigation

The Navigation object representing the completed navigation.

onNavigationRedirected

Added in 1.15.0-beta01
default void onNavigationRedirected(@NonNull Navigation navigation)

Called when a navigation is redirected.

Parameters
@NonNull Navigation navigation

The Navigation object representing the redirected navigation.

onNavigationStarted

Added in 1.15.0-beta01
default void onNavigationStarted(@NonNull Navigation navigation)

Called when a navigation starts, including same-document navigations.

Note: These navigation callbacks only fire for navigations happening on the main frame.

Parameters
@NonNull Navigation navigation

The Navigation object representing the started navigation.

onPageDeleted

Added in 1.15.0-beta01
default void onPageDeleted(@NonNull Page page)

Called when any Page is evicted/destroyed. This can occur immediately on navigation, or later if the page is BFCached and subsequently evicted.

Parameters
@NonNull Page page

The Page that was evicted or destroyed.

onPageDomContentLoadedEvent

Added in 1.15.0-beta01
default void onPageDomContentLoadedEvent(@NonNull Page page)

Called when the DOMContentLoaded event is fired for the current page.

Parameters
@NonNull Page page

The Page for which the DOMContentLoaded event fired.

onPageLoadEvent

Added in 1.15.0-beta01
default void onPageLoadEvent(@NonNull Page page)

Called when the window.load event is fired for the current page.

Parameters
@NonNull Page page

The Page for which the window.load event fired.