Android.Webview not working to track url.how can this url open in my activity

I am using android.webview in action, which works fine for the whole url, but in case of any tracking url, it will show the market details error on my screen. Should open this url after opening browser in web view.how this is only possible in my activity.

public class WebViewActivity extends Activity {
    WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);
            webView = (WebView) findViewById(R.id.webview1);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.loadUrl("http://trax.claym.in/click.php?c=209&key=c73n783g2tm2377yd73d6n5m");

        //  webView.setWebChromeClient(new WebChromeClient());
    webView.setWebViewClient(new WebViewClient(){

        @Override
        public void onReceivedError(WebView view, int errorCode,
                String description, String failingUrl) {
            if (errorCode==-10) {


                        String errormsg=description;
                String url=failingUrl;
                webView.setWebChromeClient(new WebChromeClient(){

                });
                /* Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    startActivity(intent);
                    WebViewActivity.this.finish();*/
            } 
            // TODO Auto-generated method stub
             Log.e("error code:" ,""+errorCode);
            super.onReceivedError(view, errorCode, description, failingUrl);
        }

        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view,
                String url) {
            // TODO Auto-generated method stub
             Log.e("WebResourceResponse" ,""+url);
            return super.shouldInterceptRequest(view, url);
        }

        @Override
        public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
            // TODO Auto-generated method stub
            return super.shouldOverrideKeyEvent(view, event);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // TODO Auto-generated method stub
            String myurl=url;
            Log.e("url", ""+myurl);
            return super.shouldOverrideUrlLoading(view, url);
        }
    });
            //webView.loadUrl("http://trax.claym.in/click.php?c=209&key=c73n783g2tm2377yd73d6n5m");
        //webView.loadUrl("https://www.google.co.in/");
            //animation url
    //  webView.loadUrl("http://www.dogwonder.co.uk/wp-content/uploads/2009/12/tumblr_ku2pvuJkJG1qz9qooo1_r1_400.gif");
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
         // Check if the key event was the Back button and if there history
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
            webView.goBack();
            return true;
        }
        // TODO Auto-generated method stub
        return super.onKeyDown(keyCode, event);
    }

}

      

+3


source to share





All Articles