Android的定制URI方案正确连接codeD时,类型浏览器 [英] Android custom URI scheme incorrectly encoded when type in browser

查看:117
本文介绍了Android的定制URI方案正确连接codeD时,类型浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写我的Andr​​oid应用程序,这是我要定义一个定制的URI方案,使用户可以通过在浏览器中键入一个URI,比如去到我的应用程序:安装MyApps://美食= 1和ID = 3

I am writing my android application, which I want to define a custom URI scheme, so that user can go to my app by typing a URI in browser, like: myapps://cate=1&id=3

我成功地在我的应用程序来实现这一点,但我发现,对于一些设备,浏览器对待的链接不同。

I successfully implemented this in my apps, but I discover that for some device, the browser treat the link differently.

在我的HTC Flyer的,它是否能正确打开我的应用程序,但在三星Galaxy王牌,浏览器转换的链接安装MyApps%3A%2F%2Fcate = 1%26id = 3,这是EN $ C $光盘,它只是谷歌的安装MyApps://美食= 1和ID = 3。对于我来说,而不是开放式的应用程序

In my HTC Flyer, it opens my app correctly, but in Samsung Galaxy Ace, the browser translates the link to myapps%3A%2F%2Fcate=1%26id=3, which is encoded, and it just google the "myapps://cate=1&id=3" for me instead of open the app.

我定义在清单的意图过滤器是这样的:

I define the intent filter in the manifest like this:

<intent-filter >
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="myapps"/>
</intent-filter>

在这个问题上任何帮助吗?谢谢

Any help on this issue? thanks

EDITED

我只是看着Android浏览器的源代码code,它定义它接受什么方案:

I just looked at the source code of android browser, it defined what scheme it accepts:

protected static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile(
    "(?i)" + // switch on case insensitive matching
    "(" +    // begin group for schema
    "(?:http|https|file):\\/\\/" +
    "|(?:inline|data|about|content|javascript):" +
    ")" +
    "(.*)" );

现在我明白了为什么自定义方案将无法正常工作!
任何应用程序应该只捕捉方案:HTTP,HTTPS,文件,内联,数据,大约,内容的JavaScript

Now I understand why custom scheme won't work! Any apps should only capture schemes: http,https,file,inline,data,about,content,javascript.

推荐答案

为什么它必须是一个自定义的URI?

Why does it have to be a custom uri?

我会用一个标准的URL尝试一下,那么我会定义一个广播接收器吧。

I'd try it with a standard URL and then I'd define a broadcast receiver for it.

这是本质如何 http://youtube.com 或的 http://maps.google.com 工作,我想。刚刚尝试在你的银河王牌的Andr​​oid浏览器中输入这两个网址。

That's essentially how http://youtube.com or http://maps.google.com work I think. Just try typing those two URLs in your Android browser of your Galaxy Ace.

这篇关于Android的定制URI方案正确连接codeD时,类型浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆