【问题标题】:Loading external web links from other app to my Browser从其他应用程序加载外部网络链接到我的浏览器
【发布时间】: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


【解决方案1】:

http://www.vogella.com/tutorials/AndroidIntent/article.html

参考链接。在此,他们解释了如何使用显式意图在两个应用程序之间进行通信。他们的例子也完全满足您的需求。

【讨论】:

    猜你喜欢
    • 2016-09-04
    • 2018-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-02
    • 2012-03-21
    • 1970-01-01
    • 2011-04-24
    相关资源
    最近更新 更多