title: Loading an activity from WebView - works first time app is installed but not after that?
body: <p>In the login screen (LoginActivity) of my Android app, there is a 'Sign up' button that takes the user to a registration webpage that is displayed in a WebView (in SignupActivity). After the user has registered (i.e. clicked the 'CreateAccount' button), I would like to take them back to LoginActivity. </p>
  
  <p>My current code is below. It works the first time the app is installed, but after repeating the process the 2nd time, the if/else clause doesn't trigger at all (neither of the Logs shows up and the redirection doesn't happen). Why?</p>
  
  <pre><code>public class SignupActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Log.d("SignupActivity", "Signup Activity started");
  
      WebView webView = new WebView(this);
      setContentView(webView);
  
      webView.setWebViewClient(new MyWebViewClient());
      webView.loadUrl("https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&amp;returnto=Main+Page&amp;returntoquery=welcome%3Dyes");
  
  }
  
  private class MyWebViewClient extends WebViewClient {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          if (url.equals("https://commons.m.wikimedia.org/w/index.php?title=Main_Page&amp;welcome=yes")) {
              // Signup success, so load LoginActivity again
              Log.d("SignupActivity", "Overriding URL");
  
              CookieSyncManager.createInstance(getApplicationContext());
              CookieManager cookieManager = CookieManager.getInstance();
              cookieManager.removeAllCookie();
              cookieManager.setAcceptCookie(false);
              cookieManager.removeSessionCookie();
  
              Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
              startActivity(intent);
              return true;
          } else {
              Log.d("SignupActivity", "Not overriding URL, URL is: " + Uri.parse(url).getHost());
              return false;
          }
  
      }
  
  }
  </code></pre>
  
  <p>And in LoginActivity I have attached this method to a button click:     </p>
  
  <pre><code>//Called when Sign Up button is clicked
      public void signUp(View view) {
          Intent intent = new Intent(this, SignupActivity.class);
          startActivity(intent);
      }
  </code></pre>
  
  <p>However I am new to WebViews so I am happy to change this setup if necessary.</p>