title: Returning to App from Webview on logout of web application
body: <p>I have pasted a small snippet of my code that will allow the person to click on the <code>webview</code> and return back to my login app. The web application in <code>webview</code> should only do this if they click the logout inside the web application that <em>runs in</em> the <code>webview</code>. In other words it shouldn't return to the login app just because they clicked somewhere in the webview. </p>
  
  <p>I have tried doing this using the <code>onPageStarted</code> and just can't get it to work. It ask for 3 parameters and <code>Android Studio</code> won't even compile it. It may be the way I'm trying to call it as I don't quite understand how to call that method, after reading the documentation.</p>
  
  <p>Also, I tried to make a private class called <code>myWebClient</code> to call the <code>onPageStarted</code> but can't seem to call that one either correctly in my <code>MainActivity</code>.</p>
  
  <p>Here's the working code that will take me back to my app on ANY click within the webview. </p>
  
  <pre><code>webView.setOnTouchListener(new View.OnTouchListener() {
          String checkurl;
  
          public boolean onTouch(View v, MotionEvent e) {
  
          Intent intent = new Intent(context, MainActivity.class); 
          startActivity(intent); 
          Toast.makeText(getApplicationContext(), checkurl, Toast.LENGTH_LONG).show();
  
          return false;
          }
  
          });
  </code></pre>
  
  <p>Here's what I tried which didn't work. </p>
  
  <pre><code>webView.setOnTouchListener(new View.OnTouchListener() {
              String checkurl;
              public boolean onTouch(View v, MotionEvent e) {
                  public void onPageStarted( WebView view, String url, Bitmap favicon){
                      if (checkurl == "mylogoutURLgoes here") {
  
                          Intent intent = new Intent(context, MainActivity.class); 
                          startActivity(intent); 
                      }
                      super.onPageStarted(webView, url, favicon);
                  }
                  Toast.makeText(getApplicationContext(), checkurl, Toast.LENGTH_LONG).show();
  
              }
  
          });
  </code></pre>