是否有任何监听器可以让我们知道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
中打开相应的活动答案 0 :(得分:2)
不幸的是,这是不可能的
为了在导航时保护用户的隐私,网址不会通过导航事件自动发送到主机应用。
可以通过用户点击自定义操作按钮或辅助工具栏上的其中一个按钮获取URL。
This一段代码显示了如何设置自定义操作按钮,this代码显示了如何检索由CustomAction调用的BroadcastReceiver中的URL。
答案 1 :(得分:0)
如果您认识主机,您可以设置一个 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
。它将以 onCreate
开头,带有参数 arguments?.get("_uri") as? Uri
或类似的东西,您可以进一步解析并查看用户的位置去了。