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 8882321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:32:56+00:00 2026-06-14T20:32:56+00:00

In my app I have the following structure: Activity A calls activity B, and

  • 0

In my app I have the following structure:

Activity A calls activity B, and finishes, removing itself from the stack; Activity B receives an intent from activity A that specifies some action to perform, when these actions are performed, the user will see a message indicating it (still in activity B) .If the user presses the home button the app will go to background, calling "onPause" and then "onStop". All works as expected.

The problem is that if the user leaves the app in background for a few hours, and tries to open the app again (after a few hours) the onCreate method in activity B will be called with the exact same intent as it received some hours ago from activity A.

(if the user goes back to the app a few minutes after, he will see activity B just like when he left)

What I wanted was that in this case my app would open activity A and not activity B or, activity B but with the message that was on screen when user left.

Looking at the activity life cycle it seems that the app is killing by the OS, all of this makes sense, what I really don’t understand is why activity B opens with onCreate method and the same intent as before.

  • 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-14T20:32:58+00:00Added an answer on June 14, 2026 at 8:32 pm

    Use onSaveInstanceState() to record the state of ActivityB. Android will call this before it kills the process. When the user returns to the application, it will recreate the process and then recreate whatever activity was on the top of the activity stack (in your case, ActivityB). When it does that, it will pass the saved instance state to the activity as a parameter in the onCreate() call. You should be able to put something in there so that your ActivityB can tell that it is being recreated after a process kill/restart. In that case, ActivityB could just show the user the message again (which it would have to save in the onSaveInstanceState() method) or it could just redirect the user back to ActivityA so that he can start all over again.

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

Sidebar

Related Questions

In my app I have following data structure: A ListView that user can add,
I have got following xml structure of my app activity. Now I would like
I have the following directory structure: project/ .git/ ... app/ ... config/ initializers/ braintree.rb
I have the following Node.js directory structure. |--app/ |--app.js |--routers/ |--index.js/ |--models/ |--schemas.js |--post.js
I have a JavaScript data structure like the following in my Node.js/Express web app:
I have something that looks like the following document structure: public class Document {
I have the following folder structure for the templates on my django app: templates/
I have the following structure in my app: FragmentActivity with ViewPager holding multiple fragments
I have following project structure -root -app.html -scripts/ -jquery/ locales.js -_locales/ -en/ -messages.json in
I have the following project structure: myproject | +- app | +- conf |

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.