【发布时间】:2017-10-10 08:32:03
【问题描述】:
我为我们的网站制作了一个 android webview 应用程序。现在我想向应用程序添加深层链接,例如当有人点击我们网站的链接时,您可以使用 webview 应用程序而不是 chrome 网络浏览器打开它。我将这些添加到我的清单中:
<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:scheme="https"
android:host="www.example.com" />
现在,当我单击与我们相关的链接时,它会打开 webview 应用程序,但它没有打开正确的页面,它只是再次启动应用程序。但我想在 webview 应用程序中直接打开正确的页面。
编辑:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//added
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
但似乎没有使用变量action和data。 我像这样加载网络视图(三种语言)。
//loads the main website
//sets the matching language
web2.clearCache(true);
String loc = Locale.getDefault().toString();
if (loc.startsWith("de")) {
web2.loadUrl("https://www.example.de");
} else if (loc.startsWith("nl")) {
web2.loadUrl("https://www.example.nl");
} else {
web2.loadUrl("https://www.example.com");
}
【问题讨论】:
标签: android webview deep-linking