如何在chrome自定义标签中实现URL更改侦听器?



是否有任何侦听器可以让我们知道 chrome 自定义选项卡中的 URL 已更改。

String url = ¨https://paul.kinlan.me/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));

我正在使用chrome自定义选项卡打开此链接。 我必须截取每个网址更改并在 android 中打开适当的活动

不幸的是,这是不可能的

为了在导航时保护用户的隐私,URL 不会通过导航事件自动发送到主机应用。

由于用户单击自定义操作按钮或辅助工具栏上的某个按钮,可以获取 URL。

此代码示例演示如何设置自定义操作按钮,此代码演示如何检索由自定义操作调用的广播接收器中的 URL。

如果您知道主机,则可以设置IntentFilter

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="paul.kinlan.me"
android:scheme="https"/>
</intent-filter>

对于要在其中处理此 URL 的任何Activity。它将以onCreatearguments?.get("_uri") as? Uri或类似内容开始,您可以进一步解析并查看用户去了哪里。

最新更新