How to direct user back to the app screen from webView by using onBackPressed (Kotlin)?

62 views Asked by At

I've used this but this is not what I want. Since I have only one privacy policy webpage to show there is no use of canGoBack() and it closes the app on back press. I want to just close the webView.

override fun onBackPressed() {
    val webView= findViewById<WebView>(R.id.webView)

      if (webView.canGoBack()){
          webView.goBack()}
else{
    super.onBackPressed();
    }

So if you have any solution in Kotlin please help!!

0

There are 0 answers