title: Android Studio, My Activities are going to the wrong activity
body: <p>so I am a fresh face to android development, and I encountered a problem which I have been going loops for.</p>
  
  <p>I have three activities here, they are for registration,  I don't want to implement scrollview because it isn't that good looking so I made it to three form activities, </p>
  
  <p>The first activity gathers all info from the XML's and passes the values as via intent to the second activity,
  then the second activity gathers all info from it's own XML, and then passes it together with the Extra of the first activity to the third activity, and the third activity together with the first and seconds Extras PLUS it's own values from it's own XML's, finally, saves the values to firebase.</p>
  
  <p>Yes the values get's saved, but my problem is the third activity doesn't go to the Welcome class which is supposedly written on its intent. I tried rebuilding and cleaning but it did not work. I couldn't find the bug to my work, can anyone help me out? any help is appreciated. Thanks</p>
  
  <p>Here are my three java classes, and I will also put in the welcome class incase you might want to ask for it:</p>
  
  <p><strong>Profile.java</strong></p>
  
  <pre><code>public class Profile extends Activity {
  
      //DECLARE FIELDS
  
      EditText name,username, phone, age, birth;
      Button  saveBtn;
  
      //FIREBASE REF
      DatabaseReference userRef;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_profile);
  
  
  
          //FIREBASE DATABASE REF
          userRef = FirebaseDatabase.getInstance().getReference("Users");
  
          //ASSIGN ID's
          saveBtn = (Button) findViewById(R.id.profileBtn);
          name = (EditText) findViewById(R.id.profileName);
          username = (EditText) findViewById(R.id.profileUsername);
          age = (EditText) findViewById(R.id.profileAge);
          phone = (EditText) findViewById(R.id.profilePhone);
          birth = (EditText) findViewById(R.id.profileBirth);
  
  
          // SAVE BUTTON LOGIC
  
         saveBtn.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View view) {
  
                  addUser();
  
              }
          });
      }
  
      private void addUser(){
  
  
          String userNameString = name.getText().toString();
          String userPhoneString  = phone.getText().toString();
          String userAgeString  = age.getText().toString();
          String userBirthString = birth.getText().toString();
          String userUserNameString = username.getText().toString();
  
          //GET USER KEY  FROM INTENT
          String userKey = getIntent().getStringExtra("USER_KEY");
          String userEmail = getIntent().getStringExtra("USER_EMAIL");
          String userPass = getIntent().getStringExtra("USER_PASS");
          String userID = getIntent().getStringExtra("USER_ID");
  
  
  
          if (!TextUtils.isEmpty(userNameString) &amp;&amp; !TextUtils.isEmpty(userPhoneString) &amp;&amp; !TextUtils.isEmpty(userAgeString) &amp;&amp; !TextUtils.isEmpty(userBirthString) &amp;&amp; !TextUtils.isEmpty(userUserNameString)) {
  
  
  
  
              Toast.makeText(Profile.this, "Next!", Toast.LENGTH_LONG).show();
              Intent myIntent  = new Intent(Profile.this, Profile2.class);
              myIntent.putExtra("USER_KEY", userKey);
              myIntent.putExtra("USER_NAME", userNameString);
              myIntent.putExtra("USER_PHONE", userPhoneString);
              myIntent.putExtra("USER_AGE", userAgeString);
              myIntent.putExtra("USER_BIRTH", userBirthString);
              myIntent.putExtra("USER_USERNAME", userUserNameString);
              myIntent.putExtra("USER_EMAIL", userEmail);
              myIntent.putExtra("USER_PASS", userPass);
              myIntent.putExtra("USER_ID", userID);
  
              startActivity(myIntent);
  
          } else {
              Toast.makeText(Profile.this, "Please Enter Correct Profile Details!", Toast.LENGTH_LONG).show();
              startActivity(new Intent(Profile.this, Profile.class));
  
          }
      }
  
  }
  </code></pre>
  
  <p><strong>Profile2.java</strong></p>
  
  <pre><code>public class Profile2 extends Activity {
  
      //DECLARE FIELDS
  
      EditText Address, FSN, bType, Height, Weight;
      Button saveBtn;
  
      //FIREBASE REF
      DatabaseReference userRef;
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_profile2);
  
  
  
          //FIREBASE DATABASE REF
          userRef = FirebaseDatabase.getInstance().getReference("Users");
  
  
  
  
  
  
  
          //ASSIGN ID's
          saveBtn = (Button) findViewById(R.id.profileBtn);
          Address = (EditText) findViewById(R.id.Address);
          FSN = (EditText) findViewById(R.id.FSN);
          bType = (EditText) findViewById(R.id.bType);
          Height = (EditText) findViewById(R.id.Height);
          Weight = (EditText) findViewById(R.id.Weight);
  
  
          //MOVE TO LOGIN
  
  
  
  
          // SAVE BUTTON LOGIC
  
          saveBtn.setOnClickListener(new View.OnClickListener() {
              // @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
              @Override
              public void onClick(View view) {
  
                  addUser();
              }
          });
      }
  
      private void addUser(){
  
  
  
  
  
          String AddressString = Address.getText().toString();
          String FSNString  = FSN.getText().toString();
          String WeightString = Weight.getText().toString();
          String bTypeString  = bType.getText().toString();
          String HeightString = Height.getText().toString();
  
          //GET USER KEY  FROM INTENT
          String userKey = getIntent().getStringExtra("USER_KEY");
          String userNameString = getIntent().getStringExtra("USER_NAME");
          String userPhoneString = getIntent().getStringExtra("USER_PHONE");
          String userAgeString = getIntent().getStringExtra("USER_AGE");
          String userBirthString = getIntent().getStringExtra("USER_BIRTH");
          String userUserNameString = getIntent().getStringExtra("USER_USERNAME");
          String userPass = getIntent().getStringExtra("USER_PASS");
          String userID = getIntent().getStringExtra("USER_ID");
          String userEmail = getIntent().getStringExtra("USER_EMAIL");
  
  
  
  
  
  
  
  
          if (!TextUtils.isEmpty(AddressString) &amp;&amp; !TextUtils.isEmpty(FSNString) &amp;&amp; !TextUtils.isEmpty(WeightString) &amp;&amp; !TextUtils.isEmpty(bTypeString) &amp;&amp; !TextUtils.isEmpty(HeightString)) {
  
  
  
              Toast.makeText(Profile2.this, "Go mamshie!", Toast.LENGTH_LONG).show();
  
              Intent myIntent2  = new Intent(Profile2.this, Profile3.class);
              myIntent2.putExtra("USER_KEY", userKey);
              myIntent2.putExtra("USER_NAME", userNameString);
              myIntent2.putExtra("USER_PHONE", userPhoneString);
              myIntent2.putExtra("USER_AGE", userAgeString);
              myIntent2.putExtra("USER_BIRTH", userBirthString);
              myIntent2.putExtra("USER_USERNAME", userUserNameString);
              myIntent2.putExtra("USER_ADDRESS", AddressString);
              myIntent2.putExtra("USER_FSN", FSNString);
              myIntent2.putExtra("USER_BTYPE", bTypeString);
              myIntent2.putExtra("USER_HEIGHT", HeightString);
              myIntent2.putExtra("USER_WEIGHT", WeightString);
              myIntent2.putExtra("USER_PASS", userPass);
              myIntent2.putExtra("USER_ID", userID);
              myIntent2.putExtra("USER_EMAIL", userEmail);
              startActivity(myIntent2);
  
  
          } else {
              Toast.makeText(Profile2.this, "Please Enter Correct Profile Details!", Toast.LENGTH_LONG).show();
              startActivity(new Intent(Profile2.this, Profile2.class));
  
          }
      }
  
  }
  </code></pre>
  
  <p><strong>Profile3.java</strong></p>
  
  <pre><code>public class Profile3 extends Activity {
  
      //DECLARE FIELDS
  
      EditText NPP, PCS, MC, SB, PPH;
      Button saveBtn;
  
      //FIREBASE REF
      DatabaseReference mDataRef, userRef;
  
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_profile3);
  
  
  
          //FIREBASE DATABASE REF
          userRef = FirebaseDatabase.getInstance().getReference("Users");
  
  
  
  
          //ASSIGN ID's
          saveBtn = (Button) findViewById(R.id.profileBtn);
          NPP = (EditText) findViewById(R.id.previous);
          PCS = (EditText) findViewById(R.id.previouscs);
          MC = (EditText) findViewById(R.id.miscar);
          SB = (EditText) findViewById(R.id.stillbirth);
          PPH = (EditText) findViewById(R.id.post);
  
  
          //MOVE TO LOGIN
  
  
  
  
          // SAVE BUTTON LOGIC
  
          saveBtn.setOnClickListener(new View.OnClickListener() {
              // @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
              @Override
              public void onClick(View view) {
  
                  addUser();
              }
          });
      }
  
      private void addUser(){
  
  
  
  
  
          String NoPrevPregnancies = NPP.getText().toString();
          String PreviousCS  = PCS.getText().toString();
          String Miscarriages = MC.getText().toString();
          String Stillbirth  = SB.getText().toString();
          String PostPartumHem = PPH.getText().toString();
  
          //GET USER KEY  FROM INTENT
          String userKey = getIntent().getStringExtra("USER_KEY");
          String userEmail = getIntent().getStringExtra("USER_EMAIL");
          String userPass = getIntent().getStringExtra("USER_PASSWORD");
          String userID = getIntent().getStringExtra("USER_ID");
          String userNameString = getIntent().getStringExtra("USER_NAME");
          String userPhoneString = getIntent().getStringExtra("USER_PHONE");
          String userAgeString = getIntent().getStringExtra("USER_AGE");
          String userBirthString = getIntent().getStringExtra("USER_BIRTH");
          String userUserNameString = getIntent().getStringExtra("USER_USERNAME");
          String AddressString = getIntent().getStringExtra("USER_ADDRESS");
          String FSNString = getIntent().getStringExtra("USER_FSN");
          String bTypeString = getIntent().getStringExtra("USER_BTYPE");
          String HeightString = getIntent().getStringExtra("USER_HEIGHT");
          String WeightString = getIntent().getStringExtra("USER_WEIGHT");
  
  
          mDataRef = userRef.child(userNameString);
  
  
  
  
  
  
          if (!TextUtils.isEmpty(PreviousCS) &amp;&amp; !TextUtils.isEmpty(NoPrevPregnancies) &amp;&amp; !TextUtils.isEmpty(PostPartumHem) &amp;&amp; !TextUtils.isEmpty(Miscarriages) &amp;&amp; !TextUtils.isEmpty(Stillbirth)) {
  
  
  
              User3 user = new User3(PreviousCS, NoPrevPregnancies, PostPartumHem, Miscarriages, Stillbirth);
  
  
  
              userRef.child(userNameString).setValue(user);
              mDataRef.child("USER_KEY").setValue(userKey);
              mDataRef.child("USER_PASS").setValue(userPass);//
              mDataRef.child("USER_ID").setValue(userID);//
              mDataRef.child("USER_NAME").setValue(userNameString);//
              mDataRef.child("USER_PHONE").setValue(userPhoneString);
              mDataRef.child("USER_AGE").setValue(userAgeString);
              mDataRef.child("USER_BIRTH").setValue(userBirthString);
              mDataRef.child("USER_USERNAME").setValue(userUserNameString);//
              mDataRef.child("USER_ADDRESS").setValue(AddressString);
              mDataRef.child("USER_FSN").setValue(FSNString);
              mDataRef.child("USER_BTYPE").setValue(bTypeString);
              mDataRef.child("USER_HEIGHT").setValue(HeightString);
              mDataRef.child("USER_WEIGHT").setValue(WeightString);
              mDataRef.child("USER_EMAIL").setValue(userEmail);//
  
  
  
              Toast.makeText(Profile3.this, "User Details Completed and Saved!", Toast.LENGTH_LONG).show();
              Intent myIntent1  = new Intent(Profile3.this, Welcome.class);
  
              myIntent1.putExtra("USER_KEY", userKey);
              myIntent1.putExtra("USER_EMAIL", userEmail);
              myIntent1.putExtra("USER_PHONE", userPhoneString);
              myIntent1.putExtra("USER_BIRTH", userBirthString);
              myIntent1.putExtra("USER_USERNAME", userUserNameString);
              myIntent1.putExtra("USER_NAME", userNameString);
              myIntent1.putExtra("USER_AGE", userAgeString);
              myIntent1.putExtra("USER_ID", userID);
  
              startActivity(myIntent1);
  
  
  
          } else {
  
              Toast.makeText(Profile3.this, "Please Enter Correct Profile Details!", Toast.LENGTH_LONG).show();
              startActivity(new Intent(Profile3.this, Profile3.class));
  
          }
      }
  
  }
  </code></pre>
  
  <p><strong>My welcome activity which gets some data and shows it</strong></p>
  
  <pre><code>public class Welcome extends AppCompatActivity {
  
  
      private static final String TAG = "ViewDatabase";
      //ADD FIREBASE STUFF
  
  
  
      //DECLARE FIELDS
      Button outBtn;
      TextView welcome;
      private DatabaseReference myRef, mDataRef, userRef;
      private FirebaseDatabase mFirebaseDatabase;
      private String userIDPassed;
      private String userID;
      private String userKey;
      private DrawerLayout mDrawerLayout;
      private ActionBarDrawerToggle mToggle;
  
  
  
  
      private ListView mListView;
  
      //FIREBASE AUTH FIELDS
      private FirebaseAuth nAuth;
      private FirebaseAuth.AuthStateListener nAuthlistener;
  
  
  
      //GET USER KEY  FROM INTENT
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_welcome);
  
  
          //DRAWER LAYOUT
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
          mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close);
  
  
          //ASSIGN IDS
          outBtn = (Button) findViewById(R.id.logoutBtn);
          welcome = (TextView) findViewById(R.id.WelcomeName);
          mListView = (ListView) findViewById(R.id.listview);
  
  
          //ASSIGN INSTANCE
          myRef = FirebaseDatabase.getInstance().getReference().child("Users");
          nAuth = FirebaseAuth.getInstance();
          userRef = FirebaseDatabase.getInstance().getReference("Users");
  
          FirebaseUser User = nAuth.getCurrentUser();
          userID = User.getUid();
  
  //navigation Drawer
          mDrawerLayout.addDrawerListener(mToggle);
          mToggle.syncState();
  
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          NavigationView mNavigationView = (NavigationView) findViewById(R.id.nav_menu);
          mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener(){
              @Override public boolean onNavigationItemSelected(MenuItem menuItem)
              { switch (menuItem.getItemId())
              {
                  case(R.id.nav_account): Intent accountActivity = new Intent(getApplicationContext(), Welcome.class);
                      startActivity(accountActivity);
                      break;
  
                  case(R.id.nav_exercises): Intent accountActivity1 = new Intent(getApplicationContext(), Video.class);
                      startActivity(accountActivity1);
                      break;
  
                  case(R.id.nav_tips): Intent accountActivity2 = new Intent(getApplicationContext(), Image.class);
                      startActivity(accountActivity2);
                      break;
  
                  case(R.id.nav_scheduler): Intent accountActivity3 = new Intent(getApplicationContext(), CalendarActivity.class);
                      startActivity(accountActivity3);
                      break;
                  case(R.id.nav_logout): Intent accountActivity4 = new Intent(getApplicationContext(), LoginActivity.class);
                      startActivity(accountActivity4);
                      finish();
                      break;
                  case(R.id.nav_settings): Intent accountActivity5 = new Intent(getApplicationContext(), Profile.class);
                      startActivity(accountActivity5);
                      break;
                  case(R.id.nav_info): Intent accountActivity6 = new Intent(getApplicationContext(), Info.class);
                      startActivity(accountActivity6);
                      break;
              }
              return true;
              } });
  
          //Navigation Drawer
  
  
  
  
  
          nAuthlistener = new FirebaseAuth.AuthStateListener(){
              @Override
              public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                  FirebaseUser User = firebaseAuth.getCurrentUser();
  
                  if (User != null){
  
  
                      Log.d(TAG, "onAuthStateChanged:signed_in:" + User.getUid());
                      Toast.makeText(Welcome.this, "Successfully signed in with: " + User.getEmail(), Toast.LENGTH_LONG).show();
  
  
                  }else{
  
                      Log.d(TAG, "onAuthStateChanged:signed_out" + userID);
                      Toast.makeText(Welcome.this, "Successfully signed out.", Toast.LENGTH_LONG).show();
                  }
  
  
              }
  
          };
  
  
  
  
          myRef.addListenerForSingleValueEvent(new ValueEventListener() {
  
                      @Override
                      public void onDataChange (DataSnapshot dataSnapshot){
                          showData(dataSnapshot);
                      }
  
                      @Override
                      public void onCancelled (DatabaseError databaseError){
  
                      }
  
          });
  
  
  
          outBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  nAuth.signOut();
                  finish();
                  startActivity(new Intent(Welcome.this, MainActivity.class));
              }
          });
      }
  
      private void showData(DataSnapshot dataSnapshot) {
  
  
  
          //GET USER KEY  FROM INTENT
          String userKey = getIntent().getStringExtra("USER_KEY");
          String userEmail = getIntent().getStringExtra("USER_EMAIL");
          String  userPhone = getIntent().getStringExtra("USER_PHONE");
          String userBirth = getIntent().getStringExtra("USER_BIRTH");
          String  userUserName = getIntent().getStringExtra("USER_USERNAME");
          String userName = getIntent().getStringExtra("USER_NAME");
          String userAge = getIntent().getStringExtra("USER_AGE");
          String userID = getIntent().getStringExtra("USER_ID");
  
  
          mDataRef = userRef.child(userName);
  
  
  
  
          if (!TextUtils.isEmpty(userKey) &amp;&amp; !TextUtils.isEmpty(userEmail) &amp;&amp; !TextUtils.isEmpty(userID) &amp;&amp; !TextUtils.isEmpty(userBirth) &amp;&amp; !TextUtils.isEmpty(userUserName)) {
  
  
  
  
              for(DataSnapshot ds : dataSnapshot.getChildren()){
  
                  Log.d(TAG, "showData: snapshot: " + ds);
                  Log.d(TAG, "showData: snapshot: " + ds.child("Users"));
  
  
                  //display all info taken
  
  
                  Log.d(TAG, "showData: USER_NAME: " + userName);
                  Log.d(TAG, "showData: USER_AGE: " + userAge);
                  Log.d(TAG, "showData: USER_BIRTH: " + userBirth);
                  Log.d(TAG, "showData: USER_PHONE: " + userPhone);
                  Log.d(TAG, "showData: USER_USERNAME: " + userUserName);
  
                  ArrayList&lt;String&gt; array = new ArrayList&lt;&gt;();
                  array.add(userName);
                  array.add(userAge);
                  array.add(userBirth);
                  array.add(userPhone);
                  array.add(userUserName);
                  ArrayAdapter adapter = new ArrayAdapter&lt;&gt;(this,android.R.layout.simple_list_item_1,array);
                  mListView.setAdapter(adapter);
  
              }
  
  
          } else {
  
  
          }
  
      }
  
      @Override
      protected void onStart() {
          super.onStart();
          nAuth.addAuthStateListener(nAuthlistener);
      }
  
      @Override
      protected void onStop() {
          super.onStop();
          nAuth.removeAuthStateListener(nAuthlistener);
      }
  
  
  
  
  
      //FOR NAVIGATION DRAWER
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
  
  
          if (mToggle.onOptionsItemSelected(item)){
              return true;
          }
          return super.onOptionsItemSelected(item);
  
      }
      //Navigation Drawer End
  
  }
  </code></pre>
  
  <p>What did I do wrong? Thinking of it as flowing water, I think the values flowed well until the last activity?</p>