I got it to work
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Let's display the progress in the activity titlebar, like
the browser app does
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
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 );
}
});
// Creating and setting a WebViewClient subclass.
// It will be called when things happen that impact the
rendering of the content,
// eg, errors or form submissions. You can also intercept URL
loading here (via shouldOverrideUrlLoading()).
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();
view.loadData("Your internet connection may be
down? Please restart your app.", "text/html", "UTF-8");
}
});
// Go to a web page
webview.loadUrl("http://www.MyWebsite.com");
}
}
On Feb 14, 2:51 pm, Craigbtx <[email protected]> wrote:
> Can you give me some sample code? I am learning and only done android
> programming for 2-3 weeks.
>
> On Feb 14, 2:26 pm, Mark Murphy <[email protected]> wrote:
>
>
>
> > On Mon, Feb 14, 2011 at 3:23 PM, Craigbtx <[email protected]> wrote:
> > > 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?
>
> > Call loadUrl() or loadData() or loadDataWithBaseURL() with whatever you
> > want.
>
> > --
> > Mark Murphy (a Commons
> > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android Training...At Your Office:http://commonsware.com/training- 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