其他分享
首页 > 其他分享> > 如何从Android中的Chrome Tabs获取回调,如web视图提供了shouldOverrideUrlLoading,onLoadResource,onPageFinished

如何从Android中的Chrome Tabs获取回调,如web视图提供了shouldOverrideUrlLoading,onLoadResource,onPageFinished

作者:互联网

我正在尝试使用项目中的Chrome自定义标签替换网络视图.要替换webview,我需要在Android标签提供的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;

要附加回调,请正常绑定到自定义选项卡服务,并在调用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,google-chrome,webview,chrome-custom-tabs
来源: https://codeday.me/bug/20190611/1217590.html