How to go back to p...
 
Share:
Notifications
Clear all

[Solved] How to go back to previous page if back button is pressed in WebView?

  

0
Topic starter

When I click the phone's back button, it takes me straight into my app. I want to go back to the previous page in the website instead. How can I do this?

Topic Tags
1 Answer
2

The following code will get you what you want.

 

@Override
public void onBackPressed() {
if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}

Thanks code worked.