My MainActivity is not calling onActivityResult after coming back from another activity using the onSupportNavigateUp method. I know that onSupportNavigateUp is working cause I logged it.

But when the MainActivity is returning i do not get the Log("RESULT") test, so it's not even getting to the if statement.

look at my code below

**UPDATE**: I've noticed a weird behaviour when pressing back button while on MainActivity. There seems to be multiple instances of it (like 8 or 10) before getting out of the app.

**UPDATE**: Joined my Manifest

MainActivity

```
public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    FragmentManager mManager = getSupportFragmentManager();

    FirebaseUser mCurrentUser;
    FirebaseAuth mAuth;

    private TextView mEmailHeader;

    private User mUser;

    private DatabaseReference mDatabase;

    private static final int REQUEST_CODE = 222;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mDatabase = FirebaseDatabase.getInstance().getReference();
        initializeViews();

        mUser = new User();

        mAuth = FirebaseAuth.getInstance();
        if (mAuth != null) {
            mCurrentUser = mAuth.getCurrentUser();
            String email = mCurrentUser.getEmail();
            mEmailHeader.setText(email);
            mUser.setEmail(email);
            writeNewUser(mCurrentUser.getUid(), mUser);
        }

    }

    private void writeNewUser(String userId, User user) {

        mDatabase.child("users").child(userId).setValue(user);

    }

    private void initializeViews() {

        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MyUtilty.showSnackbar(view, "Replace with your own action !");
            }
        });

        DrawerLayout drawer = findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

        View headerView = navigationView.getHeaderView(0);
        mEmailHeader = headerView.findViewById(R.id.textViewEmailHeader);

    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        switch (id) {
            case R.id.action_logout:
                FirebaseAuth.getInstance().signOut();
                finish();
                return true;

            case R.id.action_profile:
                Intent intent = new Intent(this, ProfileActivity.class);

                ```startActivityForResult(intent, REQUEST_CODE);
                return true;```
        }
        return super.onOptionsItemSelected(item);
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();

        if (id == R.id.nav_trips) {
            MyUtilty.switchFragment(mManager, new TripsFragment());

        } else if (id == R.id.nav_gallery) {
            MyUtilty.switchFragment(mManager, new GalleryFragment());

        } else if (id == R.id.nav_tips) {

        } else if (id == R.id.nav_map) {

        } else if (id == R.id.nav_share) {

        } else if (id == R.id.nav_send) {

        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        Log.d("RESULT", "TEST");

        if (requestCode == REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                if (data != null && data.hasExtra("name")) {
                    String[] array = data.getStringArrayExtra("name");
                    mUser.setFirstName(array[0]);
                    mUser.setLastName(array[1]);
                    writeNewUser(mCurrentUser.getUid(), mUser);
                    Log.d("TEST", "It's working");
                }
            }

        }

    }

}

```

ProfileActivity

```
public class ProfileActivity extends AppCompatActivity {

    private EditText mFirstName;

    private EditText mLastName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile);

        initializeViews();

    }

    private void initializeViews() {

        mFirstName = findViewById(R.id.editTextFirstName);
        mLastName = findViewById(R.id.editTextLastName);
    }

    @Override
    public boolean onSupportNavigateUp() {

        Log.d("NAV_UP", "Nav up working");
        String firstName = mFirstName.getText().toString();
        String lastName = mLastName.getText().toString();
        String[] array = {firstName,lastName};
        Intent intent = new Intent();
        intent.putExtra("name", array);
        setResult(RESULT_OK,intent);
        finish();
        return super.onSupportNavigateUp();
    }

}

```

Manifest

```
<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".ProfileActivity"
            android:parentActivityName=".MainActivity"
            android:label="Profile"></activity>
        <activity
            android:name=".LoginActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SignupActivity"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" />
    </application>

</manifest>

```