title: close webview in kivy
body: <p>iam trying to close or destroy the webview and show other layout
  here is my code for webview or if that won't possible i want to get the link of the current page and if current page link is equal to some link i want to exit the webview pls help me out this</p>
  <pre><code>from android.runnable import run_on_ui_thread as run_thread
  from jnius import autoclass
  from kivy.uix.widget import Widget
  from kivy.core.window import Window
  from kivy.uix.gridlayout import GridLayout
  from kivy.uix.button import Button
  from kivy.app import runTouchApp
  from kivy.clock import Clock, mainthread
  @mainthread
  def quit_screen():
      app = App.get_running_app()
      e=GridLayout()
      d1=button(text=&quot;hi end&quot;)
      e.add_widget(e)
      app.root.switch_screen(e)
  @run_thread
  def key_back_handler():
      webview.loadUrl(&quot;about:blank&quot;)
      webview.clearHistory()
      webview.clearCache(True)
      webview.clearFormData()
      webview.freeMemory()
      Clock.schedule_once(quit_screen, 0)
  @run_thread
  def WebView(link,*args):
      WebV = autoclass('android.webkit.WebView')
      WebViewClient = autoclass('android.webkit.WebViewClient')
      activity = autoclass('org.kivy.android.PythonActivity').mActivity
  
      webview = WebV(activity)
      settings = webview.getSettings()
      settings.setJavaScriptEnabled(True)
      settings.setUseWideViewPort(True) 
      settings.setLoadWithOverviewMode(True) 
      settings.setSupportZoom(True)
      settings.setBuiltInZoomControls(True)
      wvc = WebViewClient()
      webview.setWebViewClient(wvc)
      activity.setContentView(webview)
      webview.loadUrl(link)
  
  m=GridLayout(cols=1,rows=1)
  d=GridLayout(cols=1,rows=1)
  m.add_widget(d)
  def Push(butoon):
      WebView(&quot;https://www.google.com&quot;)
  b=Button(text=&quot;hi&quot;)
  b.bind(on_press=Push)
  d.add_widget(b)
  
  
  runTouchApp(m).run()
  </code></pre>
  <p>like this but its not closing on back pressed on android <a href="https://i.stack.imgur.com/4TArd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4TArd.jpg" alt="like this image" /></a></p>
  <p>Thanks for help in advance</p>