gpt4 book ai didi

android - 如何从 CustomTabsClient 获取 Url 更改

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:19:37 30 4
gpt4 key购买 nike

如何在页面变化时获取url,使用CustomTabsClient

例如 WebView 有一个方法:

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon){}

CustomTabs 我需要一个类似的方法。

我找到了这个:

mClient.newSession(new CustomTabsCallback(){
@Override
public void onNavigationEvent(int navigationEvent, Bundle extras) {
super.onNavigationEvent(navigationEvent, extras);
}

@Override
public void extraCallback(String callbackName, Bundle args) {
super.extraCallback(callbackName, args);
}
});

但我不确定这是否是我需要的。

最佳答案

How to get the url when the page changes, using CustomTabsClient?

不幸的是你不能。 Chromium 错误跟踪器上还有一个 Unresolved 问题:

https://code.google.com/p/chromium/issues/detail?id=543542

您现在唯一能做的就是知道选项卡何时开始或完成加载页面,但您无法检索 URL:

mClient.newSession(new CustomTabsCallback(){
@Override
public void onNavigationEvent(int navigationEvent, Bundle extras) {
Log.w(TAG, "onNavigationEvent: Code = " + navigationEvent);

switch (navigationEvent) {
case NAVIGATION_STARTED:
// Sent when the tab has started loading a page.
break;
case NAVIGATION_FINISHED:
// Sent when the tab has finished loading a page.
break;
case NAVIGATION_FAILED:
// Sent when the tab couldn't finish loading due to a failure.
break;
case NAVIGATION_ABORTED:
// Sent when loading was aborted by a user action before it finishes like clicking on a link
// or refreshing the page.
break;
}
}
});

关于android - 如何从 CustomTabsClient 获取 Url 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33343917/

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