0

I am trying to using Webview and also to pull down to refresh the CURRENT page. Everything going good except this one.

The Problem is to Refresh the current page.

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            final SwipeRefreshLayout swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe);
            browser = (WebView) findViewById(R.id.webView1);
            browser.setWebViewClient(new MyBrowser());
            browser.loadUrl("https://www.google.co.in/");

            swipeView.setColorSchemeColors(R.color.blue, R.color.purple, R.color.green, R.color.orange);

            swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                    swipeView.setRefreshing(true);
                    (new Handler()).postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            swipeView.setRefreshing(false);
                            browser.loadUrl("https://www.google.co.in/");
                        }
                    }, 4000);
                }
            });
        }

private class MyBrowser extends WebViewClient  
    {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }

as per my code Refreshing is working but when i move to some links, to refresh means the page redirect to google.com. Current page not refreshing it will redirected another URL.

0 Answers0