android - Chrome 自定义选项卡 Android 的滚动回调或侦听器
问题描述
我正在寻找以下 2 个与Android中的Chrome 自定义选项卡相关的解决方案:
如果页面 url 已完全加载(即 100%),则侦听器或回调
页面滚动或页面滚动到末尾/底部的侦听器或回调。
两者都可以通过实现WebView来实现,但我不知道如何对Chrome Custom Tab做同样的事情。我到处寻找可能的最佳解决方案,但没有找到方法。
那么任何人都可以指导我是否可以使用Chrome 自定义选项卡?
如果是,我如何在 Android 中实现它?
更新:
我发现了一些可能与第一点CustomTabsCallback##NAVIGATION_FINISHED相关的东西,但没有找到一个有效的例子。
解决方案
对于您的第一个问题,以下是我们应该实现的回调方法。
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% 确定。
推荐阅读
- excel - 在字符串 VBA 中搜索数字
- azure - 互联网出口的 Kubernetes 网络策略
- node.js - Mongoose find() 并追加到数组
- google-cloud-platform - GCloud 计算实例停止但未停止
- ios - iOS 13 UIViewController 模态演示阴影
- kubernetes-helm - 如何将 istio 注入到使用 helm 部署的部署中
- python - os.path.dirname 和 os.path.join
- angular - 如何设置圆环图的边框宽度
- java - Adempiere 隐藏/显示字段基于使用显示逻辑在客户端窗口中选中或未选中的刻度线
- c# - Xamarin.Forms-通过后退按钮关闭应用程序时保持计时器运行