我正在寻找以下2种与Android中的 Chrome自定义标签相关的解决方案:
侦听器或回调,如果页面网址已完全加载(即100%)
页面滚动或页面滚动到末尾的侦听器或回调。
都可以通过实现 WebView 来实现,但是我不知道如何使用 Chrome自定义标签来做到这一点。我到处搜索最佳解决方案,但没有找到方法。
那么任何人都可以指导我,是否可以使用 Chrome自定义标签?
如果可以,我如何在Android中实现它?
更新:
我发现了一些与第一点CustomTabsCallback##NAVIGATION_FINISHED有关的东西,但是没有找到一个可行的例子。
答案 0 :(得分:0)
对于第一个问题,以下是我们应实现的回调方法。
void onNavigationEvent(int navigationEvent, Bundle extras)
其中navigationEvent
如下
/**
* 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;
您可以在https://github.com/GoogleChrome/custom-tabs-client/blob/master/Application/src/main/java/org/chromium/customtabsclient/MainActivity.java#L111中找到使用onNavigationEvent的实现。这是Google本身的完整示例演示项目https://github.com/GoogleChrome/custom-tabs-client。
参考:https://github.com/GoogleChrome/custom-tabs-client/blob/master/Using.md#navigation
对于问题2,我不确定当前是否有办法做到这一点,但我不确定100%。