如何从像Web View这样的android中的Chrome选项卡获取回调提供了ShouldOverrideUrlLoading,onLoadResource,onPageFinished

Fai*_*han 6 android google-chrome webview chrome-custom-tabs

我正在尝试用项目中的Chrome自定义标签替换Web视图。为了替换webview,我需要在Chrome标签页中进行回调,例如android web view提供的回调。那么,有没有回调可用,如果可用,那么它们是什么?请事先帮助我。

Var*_*rma 5

您只能在 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;
Run Code Online (Sandbox Code Playgroud)

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

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

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


小智 5

在 Android 的自定义 chrome 选项卡中这是不可能的。