【发布时间】:2018-05-31 19:28:51
【问题描述】:
我已经构建了一个 Android 浏览器,我想在其中加载来自其他应用程序的外部 Web 链接。在这里,我在 AndroidManifest.xml 上添加了这段代码。因此,当我从其他应用程序打开 http/https 链接时,它会在浏览器列表中显示我的应用程序。
<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="http" />
<data android:scheme="https" />
</intent-filter>
现在,我将通过哪个键名将数据输入我的浏览器??? 假设,如果我发送一个键是 "url" 的 web 链接,那么我通过这种方式加载该 url,
Intent intent = getIntent();
String url = intent.getStringExtra("url");
if(url!=null) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
finish();
}
我不知道其他应用程序通过哪个键名发送数据以使用外部浏览器打开。我该如何解决这个问题?
【问题讨论】:
-
你想在浏览器中打开网址是吗?
-
是的。但我可以抓住 url 链接吗? (通过哪个键名)
标签: android android-intent browser webview deep-linking