Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8306605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:21:53+00:00 2026-06-08T18:21:53+00:00

I’m creating a Wizard-style application, where I need to keep the user data between

  • 0

I’m creating a Wizard-style application, where I need to keep the user data between activities A and B alive. A has a Next soft button and B has a Back soft button.

When using FLAG_ACTIVITY_REORDER_TO_FRONT I can keep the user data alive when the soft buttons are used, because each activity is reused.

But, when the user presses the Back hard button from B, B dies, due to that hard button uses finish() implicitly.

Then, I tried overriding onBackPressed in B, adding to it the same behavior as my Back soft button, thinking that the Back hard button will behave exactly like the former button (not finish B).

Now, getting back from B to A with Back hard key, everything is fine. At this point with the focus in A, when the user presses the back hard button again, the expected behavior is that the application leaves.

The problem is that expected behavior does not occur, given that B is still alive; so that overriden onBackPressed in B is still listening, and some other behavior ocurr instead.

How can I finish listening with the overriden onBackPressed in B, so that when the focus is in A the application leaves?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:21:54+00:00Added an answer on June 8, 2026 at 6:21 pm

    Well, I could solved my problem with a natural Android solution:

    Following the Krylez tip, I’ve stopped using FLAG_ACTIVITY_REORDER_TO_FRONT, so I don’t have conflicts with the hard button anymore, and now I’m recycling the Intent which starts my wizard.

    In A, I have a very common method which is called when the user presses the continue soft button to go to B. Activity A is just informative, so it doesn’t need to put Intent’s extras with user’s data when going to B, like this:

        /** Called when the user presses the Continue button*/
    public void continueButtonOnClick(View view) {
    
            Intent intent = this.getIntent();
            intent.setClass(this, StepOneRegisterWizardActivity.class);
            startActivity(intent);
    }
    

    When activity B starts, it always must seek if there are user’s data available in Intent’s extras, like this:

        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_step_one_register_wizard);
    
        // Get the components of the content layout
        usernameEditText = (EditText)findViewById(R.id.usernameEditText);
        passwordEditText = (EditText)findViewById(R.id.passwordEditText);
    
        getIntentExtras();
    }
    
    private void getIntentExtras() {
        Intent intent = this.getIntent();
    
        Bundle bundle = intent.getExtras();
        if (bundle != null) {
            usernameEditText.setText(bundle.getCharSequence("usernameEditText"));
            passwordEditText.setText(bundle.getCharSequence("passwordEditText"));
        }
    }
    

    Now, maybe from B, the user presses any back button available (soft or hard) to back to A. In this case, we need to put the user’s data in Intent’s extras, like this:

        /** Called when the user presses the Back soft button*/
    public void backButtonOnClick(View view) {
        onBackPressed();
    }
    
    @Override
    /** Called when the user presses the Back hard button*/
    public void onBackPressed() {
        finish();
    
        Intent intent = this.getIntent();
        intent.setClass(this, StepZeroRegisterWizardActivity.class);
        intent.putExtra("usernameEditText", usernameEditText.getText());
        intent.putExtra("passwordEditText", passwordEditText.getText());
        startActivity(intent);
    }
    

    Finally, when the user presses the continue soft button again, the new Activity B will have the data that user entered las time.

    I hope it helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.