gpt4 book ai didi

java - Webview 是否有任何引用其域的外部链接?

转载 作者:行者123 更新时间:2023-12-01 14:08:49 25 4
gpt4 key购买 nike

您是否知道,当您单击任何链接时,系统会询问您要使用哪个浏览器/应用程序打开它?从这个概念开始,是否可以在我的 WebView 中做到这一点?例如,当域名为 www.stackoverflow.com 时,它会询问我是否要使用我的 webview 打开该链接(仅为 stackoverflow 链接创建)?不知道我说清楚了没有。

最佳答案

<activity> 下写入以下标签在您的 AndroidManifest.xml 中。

当用户单击 StackOverflow 链接时,系统会将您的应用包含在列表中。

<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.stackoverflow.com" android:scheme="http"></data>
</intent-filter>

已更新

您可以使用getIntent()在你的Activity里面获取参数(URL)。在 onCreate 中添加以下行你的方法Activity .

    Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
String url = intent.getData().toString();
webView.loadUrl(url);
}

关于java - Webview 是否有任何引用其域的外部链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18693939/

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