在 webview 中加载 mobile.twitter 的问题 [英] Problems loading mobile.twitter in webview

查看:13
本文介绍了在 webview 中加载 mobile.twitter 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 Web 视图中加载以下 url 时,我得到的只是带有加载微调器的黑色 twitter 背景.页面被加载,因为 WebViewClient.onPageFinished 被调用.然而,页面在标准 Android 浏览器中加载正常.

When I try to load the following urls in a Webview all i get is black twitter background with loading spinner. The page is loaded, as WebViewClient.onPageFinished is called. However the page loads ok in the standard Android browser.

https://twitter.com/#!/scottyab or https://mobile.twitter.com/#!/scottyab

我认为 Twitter 改变了他们的移动网站,因为这在一个月左右前奏效了.还有其他人遇到这种情况吗?

I'm thinking Twitter changed their mobile website as this worked a month or so ago. Anyone else experiencing this?

更新:启用javascript mWebView.getSettings().setJavaScriptEnabled(true);

Updated: javascript enabled mWebView.getSettings().setJavaScriptEnabled(true);

推荐答案

通过将用户代理硬编码到 iPhone 的用户代理来解决加载问题(我发现它适用于 iPhone 版本的应用程序)

Fixed the loading issue by hardcoding the user agent to iPhone's user agent (I found it worked on the iPhone version of the app)

mWebView.getSettings().setUserAgentString("Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3");

这是一次肮脏的黑客攻击后需要洗手.

Need to wash my hands after this a dirty hack.

这篇关于在 webview 中加载 mobile.twitter 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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