How to go back to the previous page on WebView

By CodesEasy
Updated December 26, 2025

How to Go Back on WebViewWatch Video :

🎥 Embedded content (YouTube Video)

1. Open the project that we where dealing with. If you haven’t gone through the previous post go through it at Implement WebView To Navigation Drawer Activity
2. Add this java code in MainActivity.java file
* Go Down.
* Click Alt+Insert.
* Select Override Methods.
* Search for onKeyDown ( Just type it ).Codes :@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction()== KeyEvent.ACTION_DOWN){

switch (keyCode){

case KeyEvent.KEYCODE_BACK:
if (webView.canGoBack()){

webView.goBack();
}
else {

finish();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}3. Now its done.Build APK. Done .That’s all for adding Go Back on Back Press on WebView. Now on next tutorial, we would see how to add the progress bar on WebView.

Related Posts

Comments (8)

Leave a Comment

traceecurley

6 years ago

When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove people from that service? Thanks!

Vishnu

6 years ago

We will check in to that…

Tamculpin

7 years ago

I simply couldn’t depart your website before suggesting that I actually enjoyed the usual info a person supply to your guests? Is going to be back frequently in order to check out new posts

Shalandacreed

7 years ago

This page truly has all of the information I wanted concerning this subject and didn’t know who to ask.

Shannanbagwell

7 years ago

Hello, just wanted to say, I liked this blog post. It was helpful. Keep on posting!

how to grow my pennis naturally for free

7 years ago

Hey there! Do you know if they make any plugins to help with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results. If you know of any please share. Appreciate it!

how to get a bigger penid

7 years ago

Outstanding quest there. What happened after? Take care!

EloyReuber

7 years ago

Great, bing took me straight here. thanks for the post. Cheers!

EfrenBlanchet

7 years ago

I was looking at some of your articles on this site and I believe this internet site is really instructive! Keep on posting .