简体   繁体   中英

android:noHistory=“true” behavior but still catch OnActivityResult?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM