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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:21:15+00:00 2026-05-22T22:21:15+00:00

First, a short description of the problem’s background: I’ve run into troubles with handling

  • 0

First, a short description of the problem’s background:

I’ve run into troubles with handling background workers lifecycles in line with Activity lifecycle. First problem is that a new instance of activity is created whenever the configuration changes (this includes screen orientation) so I had to pull my workers from the old instance to the new one. Second, this is complicated by the fact that sometimes workers display a progress dialog and also, occasionally, they display an error dialog which the user has to interact with. Handling all that stuff – workers, dialogs, etc. – across the activity instances has grown so complex that now I clearly see it was the wrong way to go.

The right way to go, I believe, was to eliminate that re-instantiation in the first place. If that was provided then I had activities with a very straight-forward and simple lifecycle and no need for tracking workers and dialogs. This can be achieved by putting android:configChanges="..." in the manifest.

Now, the question is:

Given that activity has android:configChanges="..." which includes every possible thing (orientation, keyboard, and all the rest) – is there a guarantee that an activity is instantiated exactly once while it’s alive and not killed/re-created even in the background? The documentation is not clear about this point.

If someone knows cases when such guarantee doesn’t hold up – please let me know. And most important – how to simulate those cases in order to test against them?

I appreciate your answers very much.

PS: What documentation does say is that “system can remove your activity at any point if it wants to” – but we don’t consider it here, because that will be a new story for a new instance when the user is back to the screen which activity got removed this way. In this case we’ll simply start from the scratch like if the user just opened this screen.

  • 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-05-22T22:21:16+00:00Added an answer on May 22, 2026 at 10:21 pm

    If you are asking this, your app is probably broken.

    So — why do you care? If you can’t handle your activity being restarted, then you will break in the situation where your app’s process needs to be killed for memory while in the background and the user later returns to it.

    If you can handle being restarted, why do you care that there may be some case where the activity needs to be restarted?

    Anyway the answer is that there is no way to guarantee that the activity is never restarted, so don’t abuse android:configChanges to try to avoid that. You can’t prevent it, you just make it less obvious to yourself that your app is broken, but users will still encounter the bugs you have.

    If you are having trouble dealing with this, consider using some recent facilities like fragments and loaders in the new support library. These have a number of features that make it easier for apps to handle their activity being restarted — fragments can be retained across restarts, loaders keep their data loads active, etc.

    Also the set of possible reasons that an app may need to be restarted is not fixed. New changes can and will be added in the future, and you can’t account for them.

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

Sidebar

Related Questions

SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
Short description of the page: user searches for an account (first form is to
Short: how does modelbinding pass objects from view to controller? Long: First, based on
I'm working on my first Django application. In short, what it needs to do
First off, there's a bit of background to this issue available on my blog:
I came across an interesting problem today whilst implementing a feature into a dynamic
I am facing a problem on developing my web app, here is the description:
First shot at throwing a question on these boards so hopefully I can get
First, let's get the security considerations out of the way. I'm using simple authentication
First off, I am using Windows XP. I have multiple hard drives and it

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.