如何避免“重定向通知”来自 Android Webview 中的 Google

发布于 2024-12-27 17:11:52 字数 807 浏览 1 评论 0原文

我有一个使用 webview 和 webviewclient 的应用程序。它应该是一个基于白名单的儿童浏览器,所以我检查网址并只允许加载某些网址。一般来说它的工作原理,但是当我在谷歌上搜索并点击搜索结果时,我得到一个页面,上面写着“重定向通知 - 上一页正在将您发送到...”

我没有发布代码,因为我不知道哪个部分是相关的。谁能指点我去哪里看?

补充:问题必须是 1) Google 提供搜索结果的方式(为什么它与默认浏览器不同?),或者 2)webview如何处理它们。

我开始认为这与谷歌提供搜索结果的方式有关,因为链接在任何地方都会给出“重定向通知”。这是一个示例链接: <一href="http://www.google.com/url?sa=t&source=web&cd=2&ved=0cccqfjab&url=http%3a%2f%2faerik.com%2f&ei=dlwwt-bgc -wciqk8tkzadw&usg=afqjcnhkstsuy-erndsrb4nkkpvda_xutq" rel="nofollow">http://www.google.com/url?sa=t&source=web&cd=2&ved=0cccqfjab&url=htt p%3a%2f%2faerik.com%2f&ei=dlwwt-bgc-wciqk8tkzadw&usg=afqjcnhkstsuy-erndsrb4nkkpvda_xutq

如果 Google 以不同的方式提供我的应用程序搜索结果,是否是由于 Cookie 或用户代理的原因? webview 是否自动处理 cookie 并发送默认的用户代理?

I have a an app that uses a webview and webviewclient. It's supposed to be a whitelist based browser for kids, so I'm checking urls and only allowing certain ones to be loaded. Generally its working, but when I search on google and click a search result, I get a page that says "Redirect Notice - the previous page is sending you to..."

I am not posting code because I don't know which section is relevant. Can anyone point me where to look?

Added: The problem has to be either
1) in the way Google is serving the search results (why would it it be different than the default browser?), or
2) how the webview is handling them.

I'm starting to think it has to do with the way Google is serving search results, as the links give the "redirect notice" anywhere. Here's an example link:
http://www.google.com/url?sa=t&source=web&cd=2&ved=0cccqfjab&url=http%3a%2f%2faerik.com%2f&ei=dlwwt-bgc-wciqk8tkzadw&usg=afqjcnhkstsuy-erndsrb4nkkpvda_xutq

If Google is serving my app search results differently, could it be because of cookies or user-agents? Does a webview automatically handle cookies and send the default user-agent?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初心 2025-01-03 17:11:52

啊……我明白了。我怀疑其他人也会遇到类似的问题,因为根本原因是我在根据白名单检查 URL 时将 URL 小写,然后加载小写的 URL...有点愚蠢,但话又说回来,很多错误都是如此。

Ah... I figured it out. I doubt anyone else will have a similar issue, because the root cause was that I was lowercasing the URL as I checked it against the whitelist, then loading the lowercased URL... kind of dumb, but then again, many bugs are.

泪痕残 2025-01-03 17:11:52

使用您的谷歌帐户登录,然后访问该网址。它会起作用的。成功访问该网址后,您可以重新访问该网站。

Sign in with your google account, then visit the url. It will work. Once you successfully visited the url, you can revisit that site .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文