I have the OnReceivedError event
I get the dialog Internet Down message but the page not found still
shows in hte background.
Is there some way around this? Like show a blank screen saying "error:
Site down. Try later" or something?

Thanks


@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Needed for progress bar
        // Let's display the progress in the activity titlebar, like
the browser app does
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);

        setContentView(R.layout.main);

        // WORKS WITH PROGRESS BAR
        WebView webview = new WebView(this);
        setContentView(webview);
        WebSettings webSettings = webview.getSettings();

        setProgressBarVisibility(true);

        webview.getSettings().setJavaScriptEnabled(true);


        // Make the zoom controls visible
        webSettings.setBuiltInZoomControls(true);

            final Activity activity = this;
            webview.setWebChromeClient(new WebChromeClient() {
                public void onProgressChanged(WebView view, int progress) {
                        activity.setProgress(progress * 100 );

                }
            });


            webview.setWebViewClient(new WebViewClient() {
                public void onReceivedError(WebView view, int errorCode, String
description, String failingUrl) {
                  Toast.makeText(activity, "Internet connection down? " +
description, Toast.LENGTH_SHORT).show();
                }
            });


            // Go to a web page
            webview.loadUrl("http://www.MySite.com/Default.aspx";);

    }





On Feb 14, 12:24 pm, Mark Murphy <[email protected]> wrote:
> Implement onReceivedError() in your WebViewClient.
>
>
>
>
>
> On Mon, Feb 14, 2011 at 1:21 PM, Craigbtx <[email protected]> wrote:
> > I am using webview. If the page is not correct or the website is down,
> > how can I error trap a page not found and show the users an error page
> > or some
>
> > othe page?
>
> > I am very much a beginner so I need examples of code.
>
> >  @Override
> >    public void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
> >        setContentView(R.layout.main);
>
> >        WebView webview = new WebView(this);
> >        setContentView(webview);
>
> >        WebSettings webSettings = webview.getSettings();
> >        webSettings.setJavaScriptEnabled(true);
> >        webSettings.setBuiltInZoomControls(true);
>
> >        // No error trapping
> >        webview.setWebViewClient(new WebViewClient());
> >        webview.loadUrl("http://www.MyWebsite.com";);
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Warescription: Three Android Books, Plus Updates, One Low Price!- Hide quoted 
> text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to