Search code examples
androidandroid-activity

my MainActivity restarts when calling onStartActivity for a pop up activity but only the first time


I have a pop up activity that I created that gets called by a button press in a fragment. When I press it, it restarts the MainActivity, but only on the first time we press the button. After that it works normally.

This is the fragment's onCreateView

ImageButton profileButton = (ImageButton) 
rootView.findViewById(R.id.profile_button);

profileButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent intent = new Intent(getActivity(), Profile.class);
        intent.putExtra("currentUser", "true");
        startActivity(intent);
    }
});

Edit: I was actually able to figure it out on my own. I had my MainActivity's launchmode be SingleInstance and when I changed it to SingleTask it worked.


Solution

  • I was actually able to figure it out on my own. I had my MainActivity's launchmode be SingleInstance and when I changed it to SingleTask it worked.