Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

In my Android application I have a WebView which loads a website URL with specific data as querystring in address. I don't want simple users to be aware of passed querystrings.

However I check for Internet availability programmatically before processing the WebView, sometimes for other reasons as well as problem in browser setting or low quality Internet service etc. the webpage fails to load and WebView displays the following error:

Webpage not available

the webpage at http://www.example.com/?q=43345876987&h=sdtkljdflku324kj might be temporarily down or it may have moved permanently to a new web address

Is there any way to catch the error by Android programmatically before user and display a user friendly message instead?

My current code:

if (isOnline()){
    WebView channelmanager=(WebView) findViewById(R.id.channelmanager);
    channelmanager.getSettings().setJavaScriptEnabled(true);
    channelmanager.getSettings().setDomStorageEnabled(true);
    channelmanager.loadUrl(url);
}
else
{
    Toast.makeText(getBaseContext(), "Connection unavailable", 7000).show();
}
share|improve this question
    
I assume you meant progammatically not problematically? – Yvette 42 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.