3

I am trying to load twitter widget file in webview . My webview loads correctly but When i try to open link inside webview (link inside twitter widget file) , i get the above mentioned error & whole screen turns out blank. Below is the code i am using.

    @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);
    }
}

Any help is appreciated.

Ankit Ostwal
  • 1,033
  • 3
  • 14
  • 32
  • Hey do you get solution for your issue? – Herry Mar 28 '14 at 09:58
  • and For which website you are getting issue? – Herry Mar 28 '14 at 10:00
  • I am facing the same problem. I display embedded tweet. On Nexus 7 and Nexus 10 (Android 4.4.3), shouldOverrideUrl is called and "follow" button sends intent correctly, but with Galaxy note (4.1.2), Galaxy Neuxs (4.3), Galaxy S4 (4.4.2) or Htc one (4.4.2), the tweet becomes blank (no url redirection detected). Any clue ? – Seynorth Sep 11 '14 at 09:57

1 Answers1

1

I finally found the solution with this thread response :

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

It is because of iFrames that tweets clicks are not well detected.

Community
  • 1
  • 1
Seynorth
  • 686
  • 2
  • 8
  • 22