1

I have an app that shows the user a profile edit screen the first time he or she uses the app. Within the edit profile activity, I need to allow the user to create a profile image capture an image or select from the gallery.

I want to be able to catch OnActivityResult, but once they are done with editing profile, I don't want this to be on the stack. Setting noHistory to true kills the activity and I can't catch the result.

I want this for first time: splash screen----> edit profile ----> main menu.

When the user presses the back button from the main menu, I want the app to stop, not pop edit profile from the stack.

Any idea on how to set noHistory after I've gotten OnActivityResult?

Martin
  • 4,711
  • 4
  • 29
  • 37
  • My initial thought was overriding onBackPressed. [Something like this?][1] [1]: http://stackoverflow.com/a/9548207/2151902 – Marc Feb 18 '15 at 17:50
  • i can't even catch that - I tried a bunch, tho :). It's taken off the stack immediately with noHistory, so the code isn't running at that point. – Martin Feb 19 '15 at 03:32
  • In manifest after – Bay Oct 18 '20 at 22:24

1 Answers1

3

According to the documentation there is no way to get result in activity that is specified with "noHistory"

In this case, onActivityResult() is never called if you start another activity for a result from this activity.

You can try to achieve desire result by clearing existing stack like this:

Intent i = new Intent(context, MainMenuActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
        | Intent.FLAG_ACTIVITY_NEW_TASK
        | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);

It should start new task based on main menu activity.

andrew
  • 6,533
  • 1
  • 22
  • 19