Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android WebViewClient中获取空白页_Android_Twitter_Webview_Webviewclient - Fatal编程技术网

在Android WebViewClient中获取空白页

在Android WebViewClient中获取空白页,android,twitter,webview,webviewclient,Android,Twitter,Webview,Webviewclient,我正在尝试打开twitter链接: 在我的活动中。如果我将WebViewClient设置为webview,我将得到一个空白页面。 但当我加载url而不设置任何webviewclient时,它会正确加载页面。 有人知道什么是问题吗。下面是我的代码片段 webview = (WebView) findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); //if I comment the followin

我正在尝试打开twitter链接: 在我的活动中。如果我将WebViewClient设置为webview,我将得到一个空白页面。 但当我加载url而不设置任何webviewclient时,它会正确加载页面。 有人知道什么是问题吗。下面是我的代码片段

webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
//if I comment the following line then webpage loads properly in default Android browser.
webview.setWebViewClient(new WebViewClient() {
   public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                 Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
               }
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {

    Log.v(tag, "url :" + url);
    view.loadUrl(url);
    return true;
        }
 });
    webview.loadUrl("http://mobile.twitter.com/pawan_rathore88");
谢谢,
Pawan

在对代码进行调整后,它似乎是一个用户代理问题,似乎将其更改为桌面用户代理可以解决此问题:

  WebView web = (WebView)findViewById(R.id.webView1);
        web.getSettings().setUserAgentString("Mozilla/5.0 (Macintosh; " +
            "U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, " +
            "like Gecko) Version/5.0 Safari/533.16");

        String url = "http://mobile.twitter.com/pawan_rathore88";
        web.loadUrl(url);

这是twitter目前的一个问题,在所有WebKit移动浏览器中都会失败。

这也是我的问题所在。加载桌面版非常好,但不是移动版。如果在默认浏览器上运行,则移动版本正常运行。我认为问题在于没有很好地执行用户字符串代理。但是现在找不到。

什么是“空白”页。你的意思是说它不能加载页面时出错了吗?不,只是显示白色页面,上面什么也没有。这个链接很有用,很有趣。。。试着编写一个应用程序来加载网页,看看它是否有效。有些东西可能与之冲突。我已经写过,如果我不设置WebViewClient,只加载url,它就会像charm一样工作。有趣的是,这是你的解决方案吗?抱歉,但它加载桌面网页。android浏览器扩展了WebKit的基本功能。不要假设这么多Pawan,做些调查吧。