I have this code within onCreate
:
webView.setWebViewClient(new WebViewClient() {
final ProgressDialog progress = new ProgressDialog(MainActivity.this);
.
.
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
view.loadUrl("file:///android_asset/www/error.html");
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.openDrawer(GravityCompat.START);
progress.dismiss();
}
});
When there is no internet connection it successfully detects the error and loads error.html
. However, it refuses to open the drawer. Also, it closes the progress dialog whether I comment out that line or not. The drawer opens and closes fine when the back button is pressed:
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
drawer.openDrawer(GravityCompat.START);
}
}
Why will the drawer not open inside onReceivedError?