How to go back to the previous page on WebView

How to Go Back on WebView

Watch Video :

httpv://youtu.be//8GgKQcEey24

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.

9 thoughts on “How to go back to the previous page on WebView”

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

  2. 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!

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

  4. 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

  5. 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!

Leave a Comment