title: New Activity does not start
body: <p>I'm new to programming, and trying to learn by following tutorials. I was following one tutorial and came across one problem and don't know to resolve it. 
  In my MainActivity I'm trying to authenticate user by email and password. (works fine). After that HomenActivity supposed to start. Althought, for some reason it does not start. Unfortunatly I'm unable to understend why. If you could point me in the right direction it would be much apreciated.</p>
  
  <p>Thank you all in advance.</p>
  
  <pre><code>import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.Manifest;
  import android.content.Intent;
  import android.os.Bundle;
  import android.widget.Toast;
  
  import com.firebase.ui.auth.AuthUI;
  
  import com.firebase.ui.auth.IdpResponse;
  import com.google.android.gms.tasks.OnFailureListener;
  import com.google.android.gms.tasks.OnSuccessListener;
  import com.google.firebase.auth.FirebaseAuth;
  import com.google.firebase.auth.FirebaseUser;
  import com.google.firebase.database.DataSnapshot;
  import com.google.firebase.database.DatabaseError;
  import com.google.firebase.database.DatabaseReference;
  import com.google.firebase.database.FirebaseDatabase;
  import com.google.firebase.database.ValueEventListener;
  import com.google.firebase.iid.FirebaseInstanceId;
  import com.google.firebase.iid.InstanceIdResult;
  import com.karumi.dexter.Dexter;
  import com.karumi.dexter.PermissionToken;
  import com.karumi.dexter.listener.PermissionDeniedResponse;
  import com.karumi.dexter.listener.PermissionGrantedResponse;
  import com.karumi.dexter.listener.PermissionRequest;
  import com.karumi.dexter.listener.single.PermissionListener;
  import com.raindevteam.aservicetracking.Model.User;
  import com.raindevteam.aservicetracking.Utils.Common;
  
  import java.util.Arrays;
  import java.util.List;
  
  import io.paperdb.Paper;
  
  import static java.sql.DriverManager.println;
  
  public class MainActivity extends AppCompatActivity {
  
      DatabaseReference user_information;
      private static final int MY_REQUEST_CODE = 7117;
      List&lt;AuthUI.IdpConfig&gt; providers;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Paper.init(this);
  
          user_information = FirebaseDatabase.getInstance().getReference(Common.USER_INFORMATION);
  
          providers = Arrays.asList(
                  new AuthUI.IdpConfig.EmailBuilder().build(),
                  new AuthUI.IdpConfig.GoogleBuilder().build()
                  );
  
          Dexter.withActivity(this)
                  .withPermission(Manifest.permission.ACCESS_FINE_LOCATION)
                  .withListener(new PermissionListener() {
              @Override
              public void onPermissionGranted(PermissionGrantedResponse response) {
                  showSignInOption();
              }
  
              @Override
              public void onPermissionDenied(PermissionDeniedResponse response) {
                  Toast.makeText(MainActivity.this, "You need to Accept permission",Toast.LENGTH_SHORT).show();
              }
  
              @Override
              public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token) {
  
              }
          }).check();
      }
  
      private void showSignInOption(){
          startActivityForResult(
                  AuthUI.getInstance()
                          .createSignInIntentBuilder()
                          .setAvailableProviders(providers)
                          .build(),MY_REQUEST_CODE);
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if(requestCode == MY_REQUEST_CODE){
              IdpResponse response = IdpResponse.fromResultIntent(data);
              if(requestCode == RESULT_OK){
  
                  final FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
  
                  user_information.orderByKey()
                          .equalTo(firebaseUser.getUid())
                          .addListenerForSingleValueEvent(new ValueEventListener() {
                              @Override
                              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  
                                  if(dataSnapshot.getValue() == null){
                                      if(!dataSnapshot.child(firebaseUser.getUid()).exists()){
                                          Common.loggedUser = new User(firebaseUser.getUid(),firebaseUser.getEmail());
                                          //add to database
                                          user_information.child(Common.loggedUser.getUid())
                                                  .setValue(Common.loggedUser);
                                      }
                                  }
                                  //if user exists
                                  else{
                                      Common.loggedUser = dataSnapshot.child(firebaseUser.getUid()).getValue(User.class);
  
                                  }
  
                                  Paper.book().write(Common.USER_UID_SAVE_KEY, Common.loggedUser.getUid());
                                  updateToken(firebaseUser);
  
                                  setupUI();
  
  
                              }
  
                              @Override
                              public void onCancelled(@NonNull DatabaseError databaseError) {
  
                              }
                          });
              }
          }
      }
  
      private void setupUI(){
  
          startActivity(new Intent(MainActivity.this, HomeActivity.class));
          finish();
      }
  
      private void updateToken(final FirebaseUser firebaseUser){
          final DatabaseReference tokens = FirebaseDatabase.getInstance().getReference(Common.TOKENS);
  
          FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener&lt;InstanceIdResult&gt;() {
              @Override
              public void onSuccess(InstanceIdResult instanceIdResult) {
                  tokens.child(firebaseUser.getUid()).setValue(instanceIdResult.getToken());
  
              }
          }).addOnFailureListener(new OnFailureListener() {
              @Override
              public void onFailure(@NonNull Exception e) {
                  Toast.makeText(MainActivity.this,"Error"+e.getMessage(),Toast.LENGTH_SHORT).show();
              }
          });
      }
  }
  </code></pre>
  
  <p>No error messages displayed.</p>