javascript - shouldoverrideurlloading not called Webview Android - Stack Overflow

First of all , this post may ,look like a Possible Duplicate of other question, but I have go through m

First of all , this post may ,look like a Possible Duplicate of other question, but I have go through many questions but found them not helpful. Now My problem is that I am loading an URL in my Webview and then I want to Trace URL on each event on webview so I have set up WebviewClient for Webview and overridden shouldoverrideurlloading method, but after first Event , shouldoverrideurlloading not getting called. (worked first time)

Here is the Code I have used :

    wvSecurity = (WebView) findViewById(R.id.wvSecurity);               
    wvSecurity.getSettings().setJavaScriptEnabled(true);
    wvSecurity.getSettings().setAllowContentAccess(true);
    wvSecurity.getSettings().setAllowUniversalAccessFromFileURLs(true);     
    wvSecurity.getSettings().setBuiltInZoomControls(false);
    wvSecurity.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    wvSecurity.getSettings().setLoadWithOverviewMode(true);
    wvSecurity.getSettings().setDomStorageEnabled(true);

    wvSecurity.loadUrl("URL");

    wvSecurity.setWebViewClient(new WebViewClient() {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view,
                        final String urlStr) {
                    Log.i("URL", "::" + urlStr);
                    return false;
                }
    }

EDIT ::

Ok, The URL which I want to Trace uses POST method , Now my question is How can I trace POST URL and its data. And one thing , I dont have access to Webpage ing in so I simply cant go for GET method. Please Help !!!

First of all , this post may ,look like a Possible Duplicate of other question, but I have go through many questions but found them not helpful. Now My problem is that I am loading an URL in my Webview and then I want to Trace URL on each event on webview so I have set up WebviewClient for Webview and overridden shouldoverrideurlloading method, but after first Event , shouldoverrideurlloading not getting called. (worked first time)

Here is the Code I have used :

    wvSecurity = (WebView) findViewById(R.id.wvSecurity);               
    wvSecurity.getSettings().setJavaScriptEnabled(true);
    wvSecurity.getSettings().setAllowContentAccess(true);
    wvSecurity.getSettings().setAllowUniversalAccessFromFileURLs(true);     
    wvSecurity.getSettings().setBuiltInZoomControls(false);
    wvSecurity.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    wvSecurity.getSettings().setLoadWithOverviewMode(true);
    wvSecurity.getSettings().setDomStorageEnabled(true);

    wvSecurity.loadUrl("URL");

    wvSecurity.setWebViewClient(new WebViewClient() {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view,
                        final String urlStr) {
                    Log.i("URL", "::" + urlStr);
                    return false;
                }
    }

EDIT ::

Ok, The URL which I want to Trace uses POST method , Now my question is How can I trace POST URL and its data. And one thing , I dont have access to Webpage ing in so I simply cant go for GET method. Please Help !!!

Share Improve this question edited Jan 16, 2015 at 11:49 GOLDEE asked Jan 16, 2015 at 8:16 GOLDEEGOLDEE 2,3183 gold badges26 silver badges49 bronze badges 10
  • have you try after returning true from shouldOverrideUrlLoading ? – ρяσѕρєя K Commented Jan 16, 2015 at 8:22
  • Yeah , I tried that did nothing – GOLDEE Commented Jan 16, 2015 at 8:23
  • I have tried from 8-21 Every API – GOLDEE Commented Jan 16, 2015 at 8:24
  • @GOLDEE Sorry, misred the docs for that last ment. What kind of request are you making? GET or POST or other? Also, can you put all this info in the question so we don't pollute the ments? – CodingIntrigue Commented Jan 16, 2015 at 8:24
  • 1 Is there any to Catch the Post Url ? @RGraham – GOLDEE Commented Jan 16, 2015 at 8:29
 |  Show 5 more ments

2 Answers 2

Reset to default 2

I guess this method gets called when a hyperlink is tapped from page or some redirection happens. So make sure this thing.

I think you need to pass the url in place on "URL" so this will solve your problem.

        wvSecurity = (WebView) findViewById(R.id.wvSecurity);
        wvSecurity.getSettings().setJavaScriptEnabled(true);
        wvSecurity.getSettings().setAllowContentAccess(true);
        wvSecurity.getSettings().setAllowUniversalAccessFromFileURLs(true);
        wvSecurity.getSettings().setBuiltInZoomControls(false);
        wvSecurity.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        wvSecurity.getSettings().setLoadWithOverviewMode(true);
        wvSecurity.getSettings().setDomStorageEnabled(true);
        wvSecurity.loadUrl("http://www.google.");
        wvSecurity.setWebViewClient(new HelloWebViewClient());



    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            System.out.println("URL :: " + url);
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, final String url) {
        }
    }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745464065a4628837.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信