Android webview ::拒绝显示文档,因为X-Frame-Options禁止显示

时间:2013-10-15 11:05:03

标签: android

我正在尝试在webview中加载twitter小部件文件。 我的webview正确加载但是 当我尝试在webview中打开链接(在twitter小部件文件中链接)时,我得到上面提到的错误&整个屏幕变成空白。以下是我正在使用的代码。

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_all);

    String url = getIntent().getExtras().getString("url");

    webProgress = (ProgressBar) mCustomView.findViewById(R.id.webProgress);
    mWebView = (WebView) findViewById(R.id.web_view);
    noDataConnection = (LinearLayout) findViewById(R.id.layout_no_network);
    detector = new ConnectionDetector(this);
    mWebView.getSettings().setDomStorageEnabled(true);

    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // Log.e(TAG, "shouldOverrideUrlLoading : " + url);

            if (!detector.isConnectingToInternet()) {
                noDataConnection.setVisibility(View.VISIBLE);
                webProgress.setVisibility(View.GONE);
                return true;
            } else {
                noDataConnection.setVisibility(View.GONE);
                webProgress.setVisibility(View.VISIBLE);
                return false;
            }
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            noDataConnection.setVisibility(View.VISIBLE);
            webProgress.setVisibility(View.GONE);
        }

    });
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);

            if (newProgress >= 100) {
                Log.e(TAG, "onProgressChanged : 100%");
                webProgress.setVisibility(View.GONE);
            }
        }
    });
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);


    if (!detector.isConnectingToInternet()) {
        noDataConnection.setVisibility(View.VISIBLE);
        webProgress.setVisibility(View.GONE);
    } else {
        noDataConnection.setVisibility(View.GONE);
        webProgress.setVisibility(View.VISIBLE);
        mWebView.loadUrl(url);
    }
}

感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

我终于找到了这个线程响应的解决方案:

https://stackoverflow.com/a/11280814/555153

由于iFrames,推特点击次数未得到很好的检测。