Solved: Android Studio webView.canGoBack() not working

by Violeta León

   If you are starting developing Android Apps its possible to find problem such as: "webView.canGoBack() not working" and you'll read many solutions but nothing may seems to work. Let me explain, how I solved it and where it worked.

   I made a tabbed activity with eleven fragments. My back button kept quiting the app instead of going back to the previous page into the webview. I thought if I added the funtionality of the back button inside the fragment it will solved it. But it did not.

   All you have to do its open the, search the line: "public class MainActivity extends AppCompatActivity" and add this code: 

    public void onBackPressed(){
        WebView wv = (WebView)findViewById(;
        } else {

Just as simple as that! all your fragments with webview will go back with the phone or table back button. 

Recommended lectures:

  • Android Studio 3.3 Development Essentials - Android 9 Edition: Developing Android 9 Apps Using Android Studio 3.3, Java and Android Jetpack.
  • Android Studio 3.3 Development Essentials - Kotlin Edition: Developing Android 9 Apps Using Android Studio 3.3, Kotlin and Android Jetpack
  • Learn all about how to make Android apps in this very detailed Android app development course.


Popular posts from this blog

#diy Encender Celular Sin Batería

[UPDATE 2020: APPNANA SCAM] AppNana Invitation Codes AppNana Códigos de Invitación

Ejercicios Resueltos de c++ para Principiantes