简体   繁体   English

intent:URI无法在Android浏览器中运行

[英]intent: URI not working in Android browser

So I'm clicking on this link: 所以我点击这个链接:

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

(I know its a silly example, since it could just be http://www.google.com , but its illustrative of the problem) (我知道这是一个愚蠢的例子,因为它可能只是http://www.google.com ,但它说明了问题)

I determined this URI from 我确定了这个URI

Log.v(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://www.google.com")).toUri(
                    Intent.URI_INTENT_SCHEME));

I see the following in logcat: 我在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

Rather than redirecting to www.google.com I get the "Web page not available" page. 而不是重定向到www.google.com我得到“网页不可用”页面。

If I launch the identical intent using the am binary, it succeeds. 如果我使用am二进制文件启动相同的意图,它会成功。

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

I see this in logcat 我在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 }

The ultimate goal is to have a URL that launches a specific activity in an app (and theres no way for someone to get to this page without having the app installed). 最终目标是拥有一个在应用程序中启动特定活动的URL(并且在没有安装应用程序的情况下,某人无法访问此页面)。 I know I can also define a custom scheme, but since its a global namespace I'd rather not do that. 我知道我也可以定义一个自定义方案,但由于它是一个全局命名空间,我宁愿不这样做。 I also know I can use http:// for this purpose, but I don't want the user to be prompted whether they want to open the URL in the browser or my app. 我也知道我可以使用http://为此目的,但我不希望系统提示用户是否要在浏览器或我的应用程序中打开URL。

Any ideas? 有任何想法吗?

I ran into the same problem 我遇到了同样的问题

Adding the following code to my Activity in the AndroidManifest.xml solved my problem: 将以下代码添加到AndroidManifest.xml中的Activity中解决了我的问题:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM