gpt4 book ai didi

android - 如何从 Android 中的 Chrome 选项卡获取回调,例如 web View 提供了 shouldOverrideUrlLoading、onLoadResource、onPageFinished

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:49:13 26 4
gpt4 key购买 nike

我想在我的项目中用 Chrome 自定义标签替换 WebView 。为了替换 webview,我需要像 android web view 提供的那样在 Chrome 选项卡中进行回调。那么是否有任何回调可用或不可用,如果可用,那么它们是什么?请帮我。提前致谢。

最佳答案

您只能在 chrome 自定义标签中提供以下回调:

/**
* Sent when the tab has started loading a page.
*/
public static final int NAVIGATION_STARTED = 1;

/**
* Sent when the tab has finished loading a page.
*/
public static final int NAVIGATION_FINISHED = 2;

/**
* Sent when the tab couldn't finish loading due to a failure.
*/
public static final int NAVIGATION_FAILED = 3;

/**
* Sent when loading was aborted by a user action before it finishes like clicking on a link
* or refreshing the page.
*/
public static final int NAVIGATION_ABORTED = 4;

/**
* Sent when the tab becomes visible.
*/
public static final int TAB_SHOWN = 5;

/**
* Sent when the tab becomes hidden.
*/
public static final int TAB_HIDDEN = 6;

要附加回调,请像往常一样绑定(bind)到自定义选项卡服务,并在调用 newSession() 时传递回调。

更多信息:https://developer.android.com/reference/android/support/customtabs/CustomTabsClient.html#newSession(android.support.customtabs.CustomTabsCallback)

实现指南:https://developer.chrome.com/multidevice/android/customtabs#implementationguide

关于android - 如何从 Android 中的 Chrome 选项卡获取回调,例如 web View 提供了 shouldOverrideUrlLoading、onLoadResource、onPageFinished,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43718911/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com