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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:22:43+00:00 2026-05-23T17:22:43+00:00

I have an Android App with a number of activities. The wrong activity is

  • 0

I have an Android App with a number of activities. The wrong activity is being started sometimes.

Normally, an Application subclass starts, then start activity (StartAct… android:name=”android.intent.action.MAIN”, android:name=”android.intent.category.LAUNCHER”)
does some work and then launches InitializeActivity. This does some work and then fires off my main display activity (MainAct). The first two activities do some essential initialization including setting a static “isInitialized” flag just before the intent is launched for the MainAct.

Activities are launched with startActivity() using a specific intent (…activity.class specified), and call finish() after startActivity().

However, here is what sometimes happen, and I don’t know why…

In short, the app is killed and when the icon is pressed to start it, it jumps straight to the third (MainAct) activity. This causes the app to detect an error (isInitialized flag is false) and stop:

  • Launch the app normally with the Icon:
  • …Application subclass starts, also fires up some worker threads
  • …StartActivity runs, then fires InitializeActivity and finishes
  • …InitializeActivity runs, then sets isInitialized and starts MainAct and finishes
  • …MainAct starts, runs okay
  • …Home button is hit and Angry Birds is run
  • …MainAct logs onPause, then onStop.
  • …Worker threads owned by Application subclass continue to periodically do stuff and log.
  • After 25 minutes, the entire application is suddenly killed. This observation is based on thhe end of logging activity,
  • Time goes by
  • Home button hit
  • Launcher ICON is pressed for the app
  • Application subclass onCreate is called and returns
  • *MainAct.onCreate is called! (no StartAct, no InitializeActivity)*

What am I missing?

Note: the initialize flag was added because of this issue. It is set in the only place in the code that starts the main activity, and checked only in onCreate in the main activity.

[per request]
Manifest file (slightly redacted). Note that the service in here is not currently used.

<manifest
  xmlns:android="http://schemas.android.com/apk/res/android"
  package="xxx.yyy.zzz"
  android:versionCode="1" android:versionName="1.0.1">
  <application
    android:icon="@drawable/icon_nondistr"
    android:label="@string/app_name"
    android:name=".app.MainApp"
    android:debuggable="true">
    <activity
      android:label="@string/app_name"
      android:name=".app.StartAct" android:theme="@android:style/Theme.NoTitleBar">
      <intent-filter>
        <action
          android:name="android.intent.action.MAIN" />
        <category
          android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity
      android:label="Html"
      android:name=".app.HtmlDisplayAct"/>
    <activity
      android:label="Init"
      android:configChanges="orientation"
      android:name=".app.InitializeActivity" android:theme="@android:style/Theme.NoTitleBar"/>
    <activity
      android:label="MyPrefs"
      android:name=".app.PrefsAct" />
    <activity
      android:label="@string/app_name"
      android:theme="@android:style/Theme.NoTitleBar"
      android:name=".app.MainAct">
    </activity>
    <service
      android:name=".app.svcs.DataGetterService" />
  </application>
  <uses-sdk android:minSdkVersion="4"/>
  <uses-permission
    android:name="android.permission.INTERNET" />
  <uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission
    android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission
    android:name="com.android.vending.CHECK_LICENSE" />
  <uses-feature
    android:name="android.hardware.location.network"
    android:required="false" />
</manifest>
  • 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-23T17:22:43+00:00Added an answer on May 23, 2026 at 5:22 pm

    The fact that the application is killed because of low memory should be transparent to the users. This is why when the application is killed, Android remembers what was the last activity running in this application, and creates directly this activity when the user returns to the application.

    Perhaps you could do something in the onCreate() method of your Application (or of your MainAct) to ensure that everything is properly initialized.

    By the way, unless you really need to, you shouldn’t have worker threads doing some work when the user is not using your application. Depending on what you do this could drain the battery quickly, or make the user think that it could drain the battery quickly (which is worse, because the user will uninstall your app!)

    You could also make the application finish every activity when the user is quitting the application,

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

Sidebar

Related Questions

I have an Android app which includes an activity called Help This uses a
I have an android app which asks a question followed by x number of
I have a simple android app that has quite a number of buttons, all
Hello i have problem with my sms aplication. import java.util.ArrayList; import java.util.List; import android.app.Activity;
Hello i have a problem with this aplication. import java.util.ArrayList; import java.util.List; import android.app.Activity;
I have a superclass for my Activities (WhereWolfActivity) in my Android app that has
In my Android app, I have a tabbed Activity . In one of the
I have android app . i should pass the data from android to web
We have an Android app and a Web Service. We want to download part
I have an Android app with a ListActivity in the main view. The list

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.