【问题标题】:intent: URI not working in Android browser意图:URI 在 Android 浏览器中不起作用
【发布时间】:2011-11-07 01:14:43
【问题描述】:

所以我点击了这个链接:

<a href="intent://www.google.com#Intent;scheme=http;action=android.intent.action.VIEW;end">Google</a>

(我知道这是一个愚蠢的例子,因为它可能只是 http://www.google.com,但它说明了问题)

我从

确定了这个 URI
Log.v(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://www.google.com")).toUri(
                    Intent.URI_INTENT_SCHEME));

我在 logcat 中看到以下内容:

08-02 08:32:34.708 I/ActivityManager(   71): Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://www.google.com cmp=com.android.browser/.BrowserActivity }
08-02 08:32:34.748 E/Tab     ( 4188): onReceivedError -10 intent://www.google.com#Intent;scheme=http;action=android.intent.action.VIEW;end The protocol is not supported

我没有重定向到 www.google.com,而是看到“网页不可用”页面。

如果我使用 am 二进制文件启动相同的意图,它会成功。

adb -e shell am start -d http://www.google.com -a android.intent.action.VIEW

我在 logcat 中看到了这个

08-02 08:47:42.488 I/ActivityManager(   71): Starting activity: Intent { act=android.intent.action.VIEW dat=http://www.google.com flg=0x10000000 cmp=com.android.browser/.BrowserActivity }

最终目标是拥有一个在应用程序中启动特定活动的 URL(如果没有安装应用程序,某人无法访问此页面)。我知道我也可以定义一个自定义方案,但由于它是一个全局命名空间,我宁愿不这样做。我也知道我可以为此目的使用 http://,但我不希望用户被提示是否要在浏览器或我的应用中打开 URL。

有什么想法吗?

【问题讨论】:

    标签: android android-intent intentfilter


    【解决方案1】:

    我遇到了同样的问题

    在 AndroidManifest.xml 中将以下代码添加到我的 Activity 中解决了我的问题:

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-11
      • 1970-01-01
      • 2014-10-13
      • 2016-11-21
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多