First, "Webpage not available" is the error page that webviewclient throws when an error occurs. Setting a custom webviewclient and overriding onReceiverError will handle the errors that your webview will receive.
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
//some codes here that you want to do when webview receives an error
}
});
Second, have you set the manifest correctly for a network connection? anyway just add these three:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Third, to go to a link without relaunching an app, you have to:
Add this code to where you build your webview
if(savedInstanceState == null)
{ wv.loadUrl( url here ); }
Add these two methods:
@Override
protected void onSaveInstanceState(Bundle outState )
{
super.onSaveInstanceState(outState);
wv.saveState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onSaveInstanceState(savedInstanceState);
wv.restoreState(savedInstanceState);
}
Third, on reloading the page, what I do is
- Override onCreateOptionsMenu, and make an xml for it. you can easily google how to do this
- Inflate it
getMenuInflater().inflate(R.menu.main, menu);
- Override onOptionsItemSelected and add items, also can be easily googled.