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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:22:34+00:00 2026-06-02T19:22:34+00:00

It seems like my Android app starts on the wrong activity. The important part

  • 0

It seems like my Android app starts on the wrong activity.

The important part from AndroidManifest.xml:

“MainActivity” should be the activity that is started on app launch:

<activity android:name=".MainActivity" android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="AnotherActivity"
    android:label="@string/app_name">
</activity>

MainActivity:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //display into log that THIS activity is started
        Log.d("tag", "MainActivity");

        //start async task to install the database on first startup
        progressDialog = ProgressDialog.show([params...]);
        new InstallDatabaseTask().execute(this);
}

/**
 * 1. Installs and initializes the database.
 * 2. Opens another activity.
 */
private class InstallDatabaseTask extends AsyncTask {

        @Override
        protected Object doInBackground(Object... params) {
            progressDialog.show();

            //open database so it can be installed
            MyOpenHelper helper = new MyOpenHelper((Context) params[0]);
            helper.getWritableDatabase().close();

            //dismiss progress dialog
            MainActivity.this.progressDialog.dismiss();

            //start another activity
            Intent intent = new Intent(MainActivity.this, AnotherActivity.class);
            ((Context)params[0]).startActivity(intent);

            return null;
        }
}

AnotherActivity:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //just make sure this activity was started
        Log.d("tag", "another activity started");   
    }

But the log only displays “another activity started”.

  • 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-02T19:22:36+00:00Added an answer on June 2, 2026 at 7:22 pm

    From your code i understood that android is launching the correct activity.

    But in your oncreate method you are calling async task so as soon as main activity creates it launches async task and in your async task you are calling below lines

    //start another activity
    Intent intent = new Intent(MainActivity.this, AnotherActivity.class);
    ((Context)params[0]).startActivity(intent);
    

    so as soon as async task do its task it launches another activity. so you are assuming that android is launching wrong activity. But internally you are launching the activity and in your your async is completed in just few micro seconds so you are assuming that wrong activity is launched..

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

Sidebar

Related Questions

Does switching activities in Android start a fresh JVM? It seems like each activity
I'm having some problems with proguard when optimizing my android app. It seems that
I have an android app that is setup to start a Java activity (call
I have an android app that repeatedly collects fingerprints from the wifi-networks that are
Seems like this should be obvious, but how do I send arrow key presses
Seems like this should be simple, but powershell is winning another battle with me.
This seems like it should be obvious but I can't figure it out. Suppose
After reading some posts like this one: Choose File Dialog It appears that Android
in my android app i have an ui-update-thread that keeps all my views up-to-date.
I'm refactoring some code so that my app will pull data from a website

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.