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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:49:45+00:00 2026-06-17T02:49:45+00:00

My app has several Activities, including StartActivity which is declared with <intent-filter> <action android:name=android.intent.action.MAIN

  • 0

My app has several Activities, including StartActivity which is declared with

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

in the manifest. I also have an Application subclass, and it is here that some initialization tasks are kicked off. The initialization code executes in a background thread, so StartActivity simply displays a splash screen and waits for the background initialization to complete. It is important that control does not pass to any other Activity until the initialization is complete.

Occasionally, after my app has been running, it will be sent to the background by the user pressing the HOME key, and possibly some other apps being opened. If my app is relaunched from the launcher after a short while, the app resumes happily in whatever Activity was active when the app was last open. This is fine.

If there is a delay of a couple of hours before my app is relaunched, then funny things start happening. It appears that the process is restarted – I can tell from log output that my Application.onCreate() has been called, and the background initialization task is started – but, critically, StartActivity is bypassed and the system has attempted to go straight to whatever Activity was active last time the app was open.

This seems to me like an impossible situation. It should never be possible for the process to be relaunched (after previously having been terminated, presumably due to inactivity) and jump directly to a non-MAIN Activity. Either the app is alive, and the last-used Activity can simply be resumed without the app having to reinitialize; or, the app is dead and should reinitialize from scratch, including launching the MAIN Activity. It should never be in this weird zombie state.

Is my understanding wrong, or is Android doing something totally crazy?

Possibly related: Android: When do classes get unloaded by the system?

  • 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-17T02:49:46+00:00Added an answer on June 17, 2026 at 2:49 am

    Your Application is in a “stopped” state, hidden, what you called “zombie-state”.

    When restarting it is calling the onRestart() method of your Activity which was open last time.
    You need to implement onRestart() method in this Activity.

    There you should reinitialize your Application.

    For more Information:
    http://developer.android.com/training/basics/activity-lifecycle/stopping.html

    Additional recommendation:

    First you should check if initialization is really necessary.
    In case your initialization-process is an Async-Task you could start it here (maybe with a dialog) or you could send the user straight back to the SplashScreen/MainActivity.

    protected void onRestart() {
        super.onRestart();
        if (!this.getApplicationContext().getIsInitialized()
          && !(this instanceof SplashScreenActivity)) {
          Log.v(TAG, "onRestart() starting Initialization of Application");
          initialize();
        } else {
           Log.v(TAG, "onRestart() Application already initialized");
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're designing an Android app that has several activities which are working in a
My Android app comprises several activities: M (main or root), A , B ,
My app has several activities. I need to determine which one of them is
I have an Android app with a main tab activity, and several activities within
My app has several activities which can be thought of as separate levels in
My app has several buttons which trigger different events. The user should NOT be
I have a winforms app and the main (and only) form has several buttons.
I have a document-based Core Data app. My main Core Data entity has several
My app has an options menu that is available in almost all Activities, which
I'm building an app that has several different sections to it, all of which

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.