在Android网页浏览器中打开URL会导致谷歌搜索 [英] Opening URL on Android web browser causes Google search

查看:364
本文介绍了在Android网页浏览器中打开URL会导致谷歌搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题,在浏览器中打开特定URL。首先我用下面的code,启动浏览器:

I'm having a slight problem opening a certain URL in the browser. First of all I use the following code to launch the browser:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Globals.currentChatURL)); 
startActivity(Intent.createChooser(browserIntent, "Select browser:"));

现在如果我设置Globals.currentChatURL喜欢的东西 http://www.google.com 然后它打开该网站就好了。但我的网址有点复杂,因为它包含多个参数,这些参数都是连接的base64 codeD。这里是我的网址外观的例子:

Now if I set Globals.currentChatURL to something like http://www.google.com then it opens that site just fine. But my URL is a little more complicated as it contains multiple parameters which are all base64 encoded. Here is an example of how my URL looks:

http://webportal.mysite.com/ChatProgram/chat.php ? intgroup=UFYyMA==&intid=UFYyMEZN&hg=Pw__&$p$pf=user&en=U0NPVFQgTUlMTEFS&ee=cGF1bGdAbWFnbmF0ZWNoLmNvbQ==&eq=UFRWRkVI&ec=TUFHTkFURUNI

http://webportal.mysite.com/ChatProgram/chat.php? intgroup=UFYyMA==&intid=UFYyMEZN&hg=Pw__&pref=user&en=U0NPVFQgTUlMTEFS&ee=cGF1bGdAbWFnbmF0ZWNoLmNvbQ==&eq=UFRWRkVI&ec=TUFHTkFURUNI

现在,如果我用我上面code,试图启动此网址它带给我的谷歌搜索页面以下消息:

Now if I use my above code to try and launch this URL it brings me to the Google search page with the following message:

您的搜索 - 的http:// URLabove ...未找到任何文件

"Your search - http://URLabove ... did not match any documents"

然而,如果我复制网址并将其粘贴到地址栏中它带给我到正确的位置。我怎样才能解决这个问题?这整点是让用户单击该按钮,网站推出,而不是为用户必须手动复制并粘贴URL。

Yet if I copy the URL and paste it into the address box it brings me to the right place. How can I fix this?? The whole point of this is to have the user click the button and the site to launch, not for the user to have to copy and paste the URL manually.

任何建议将是极大的AP preciated。

Any suggestions would be greatly appreciated.

非常感谢

推荐答案

有在你的HTTP URI的查询部分多余的等号。这种迹象有特定含义的形式分隔符&安培;为parameter = value
这个等号再从你的base64编码presents填充值(2 0 1)。

There is unwanted equal signs in the query part of your http URI. Such signs have a specific meaning as delimiters in the form &parameter=value. This equal signs represents padding values (0, 1 or 2) from your base64 encoding.

您可以


  • 删除它们,因为你的base64服务器德codeR不会打扰他们重建或

  • remove them because your base64 server decoder won't bother reconstructing them, or

%的E​​N code 他们(与所有其他保留字符)。

percent encode them (with all other reserved characters).

在Android版,您可以使用EN百分之code是这样的:

In android you can use percent encode this way:

String value = URLEncoder.encode("annoying values with reserved chars &=#", "utf-8");
String url = "http://stackoverflow.com/search?q=" + value;

借助 RFC 2396 现在pcated德$ P $但这是URI.parse( )是基于如由文档:

The RFC 2396 is now deprecated but that is what URI.parse() is based on as stated by the documentation:

uriString中符合RFC 2396-,连接codeD URI

uriString an RFC 2396-compliant, encoded URI

这篇关于在Android网页浏览器中打开URL会导致谷歌搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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