A
A
Alexey2014-09-09 08:43:38
Android
Alexey, 2014-09-09 08:43:38

Why does the system back button of an android smartphone kick out of the app?

I have a simple webview application. When you walk through its pages, then you click on the system "Back", the application crashes, instead of the expected return to the previous page. Why is this happening and how can it be corrected?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
linreal, 2014-09-09
@alexeidumansky

Hello,
to redefine the behavior of the back button for your purposes, use the following method:

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

A
Alexey, 2014-09-09
@alexeidumansky

Thanks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question