title: How to redirect google sign in button
body: <p>After adding the Google sign in button, connected with Firebase of course, where do i add the redirect after the user signs in to a new activity?</p>
  
  <p>tried adding it in the same function as the button, no errors or anything, the app just crashes</p>
  
  <p>here's the main java code:</p>
  
  <pre><code>package com.example.firebase.firebaseyoutube;
  
  import android.content.Intent;
  import android.support.annotation.NonNull;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  
  import com.google.android.gms.auth.api.Auth;
  import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
  import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
  import com.google.android.gms.auth.api.signin.GoogleSignInResult;
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.api.GoogleApiClient;
  import com.google.android.gms.tasks.OnCompleteListener;
  import com.google.android.gms.tasks.Task;
  import com.google.firebase.auth.AuthCredential;
  import com.google.firebase.auth.AuthResult;
  import com.google.firebase.auth.FirebaseAuth;
  import com.google.firebase.auth.FirebaseUser;
  import com.google.firebase.auth.GoogleAuthCredential;
  import com.google.firebase.auth.GoogleAuthProvider;
  
  public class MainActivity extends AppCompatActivity implements     GoogleApiClient.OnConnectionFailedListener, View.OnClickListener {
      private static int RC_SIGN_IN = 0;
      private static String TAG = "MAIN_ACTIVITY";
      private GoogleApiClient mGoogleApiClient;
      private FirebaseAuth mAuth;
      private FirebaseAuth.AuthStateListener mAuthListener;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mAuth = FirebaseAuth.getInstance();
      mAuthListener = new FirebaseAuth.AuthStateListener() {
          @Override
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
              FirebaseUser user = firebaseAuth.getCurrentUser();
              if(user != null)
                  Log.d("AUTH", "user logged in: " + user.getEmail());
              else
                  Log.d("AUTH", "user logged out.");
          }
      };
  
      GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
              .requestIdToken(getString(R.string.default_web_client_id))
              .requestEmail()
              .build();
  
      mGoogleApiClient = new GoogleApiClient.Builder(this)
              .enableAutoManage(this, this)
              .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
              .build();
  
      findViewById(R.id.sign_in_button).setOnClickListener(this);
      findViewById(R.id.sign_out_button).setOnClickListener(this);
  }
  
  @Override
  protected void onStart() {
      super.onStart();
      mAuth.addAuthStateListener(mAuthListener);
  }
  
  @Override
  protected void onStop() {
      super.onStop();
      if(mAuthListener != null)
          mAuth.removeAuthStateListener(mAuthListener);
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if(requestCode == RC_SIGN_IN){
          GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
  
          if(result.isSuccess()){
              GoogleSignInAccount account = result.getSignInAccount();
              firebaseAuthWithGoogle(account);
          }
          else
              Log.d(TAG, "Google Login Failed");
  
      }
  }
  
  private void firebaseAuthWithGoogle(GoogleSignInAccount acct){
      AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
      mAuth.signInWithCredential(credential)
              .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                  @Override
                  public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                      Log.d("AUTH", "signInWithCredential:oncomplete: " + task.isSuccessful());
                  }
              });
  }
  
  private void signIn(){
      Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
      startActivityForResult(signInIntent, RC_SIGN_IN);
  }
  
  private void signOut(){
      FirebaseAuth.getInstance().signOut();
  }
  
  @Override
  public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
      Log.d(TAG, "Connection failed.");
  }
  
  @Override
  public void onClick(View view) {
      switch(view.getId()){
          case R.id.sign_in_button:
              signIn();
              break;
          case R.id.sign_out_button:
              signOut();
              break;
      }
  }
  }
  </code></pre>