I'm new to Android, working on a webview app. I have created a custom HTML error page in asset folder for loading when internet not available, it is working fine.
My issue is when internet is back, after browsing different screen on back button press it shows the error page also, how to skip this.
@Override
public void onBackPressed() {
if (myWebView.canGoBack()) {
myWebView.goBack();
} else {
DashActivity.super.onBackPressed();
}
}
CodePudding user response:
In the no internet activity, when you open another activity on getting the internet connection back, you are forgetting to finish()
the activity. Due to that, the activity opens again.
CodePudding user response:
There can be error because you didn't finish the activity so, Instead of DashActivity.super.onBackPressed() just write finish() ;