Android的web视图问题Twitter的即使启用DomStorageEnabled [英] Android Webview issue for Twitter even with DomStorageEnabled enabled

查看:1018
本文介绍了Android的web视图问题Twitter的即使启用DomStorageEnabled的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经测试上的Galaxy Note 2.3以下问题,索尼平板电脑3.2以及银河Ÿ2.3和问题是100%可再现。由于许多线程, webview.getSettings()建议setDomStorageEnabled(真); 的伎俩。但我观察,当加载网页视图twitter.com,它的一片空白的第一次。然后,如果我说 webview.reload()或再次调用加载地址然后正确叽叽喳喳每加载,直到我退出程序(preferably部队从设置停止)的时间。这个问题是发生于这给Web控制台错误的所有网站。如果我重新加载相同的网站,那么它的加载正确。是具有相同的问题的人?

以下是code我使用的一个小片段。

 的WebView =新的网页视图(activity.context);
webview.getSettings()setJavaScriptEnabled(真)。
。webview.getSettings()setBuiltInZoomControls(真);
webview.getSettings()setDomStorageEnabled(真)。
webview.loadUrl(http://www.twitter.com);


解决方案

硬编码的UserAgent对其他线程的建议解决了这个问题。

  webview.getSettings()setUserAgentString(Mozilla的/ 5.0(Linux的; U; Android 2.0的; EN-US; Droid的编译/ ESD20)为AppleWebKit / 530.17(KHTML,例如Gecko)版本/ 4.0移动版Safari / 530.17);

什么将是使坏的缺点是什么?它会影响网站装上平板电脑吗?
用户将能去到桌面的网站,如果他们想?

I have tested the following issue on Galaxy Note 2.3, Sony tablet 3.2 as well as Galaxy Y 2.3 and the issue is 100% reproducable. As suggested on many threads , webview.getSettings().setDomStorageEnabled(true); does the trick. But i am observing that first time when the Webview loads twitter.com , its going blank . Then if i say webview.reload() or again call load Url then twitter loads correctly every time until i exit the app (Preferably Force stop from settings) . This issue is happening for all sites which give WebConsole error. If i reload the same site , then its loading correctly. Is anyone having the same issue ?

Following is a small snippet of code i use.

webview = new Webview(activity.context);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setDomStorageEnabled(true); 
webview.loadUrl("http://www.twitter.com");

解决方案

Hardcoding the Useragent as suggested on other threads solved the problem

webview.getSettings().setUserAgentString("Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");

What will be the disadvantages of this dirty trick ? Will it affect the sites loading on a tablet ? Will users be able to go to the desktop site if they want to ?

这篇关于Android的web视图问题Twitter的即使启用DomStorageEnabled的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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