0

EDIT!: The title explains the problem but I left it out of the post text. When the app is launch it launches the main activity instead of the launch activity. I even have the intent filter on the launcher activity. I have a splash screen that displays itself for 1 second then loads the main activity.

Here is the code that waits 1 second then launches the activity.

   if (start == 1) {
        android.os.SystemClock.sleep(delay);
        Intent start = new Intent(this, MainActivity.class);
        startActivity(start);
    }

Here is the android manifest that says that LaunchActivity is the laucher.

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

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

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >

    </activity>

</application>

AlexMcG
  • 165
  • 1
  • 2
  • 12
  • What I did was to set the category for the ScreenSaver Activity as `LAUNCHER`. and the MainActivity as `DEFAULT`. But you didn't set any `intent-filter` for the MainActivity. – Phantômaxx Mar 30 '15 at 18:23
  • so whats the issue here ? – Heshan Sandeepa Mar 30 '15 at 18:29
  • I added the DEFAULT code and it made no difference. – AlexMcG Mar 31 '15 at 01:15
  • I was having a similar issue and finally realized it was Android Studio running the wrong activity in the run as... dialog, this answer helped me out: http://stackoverflow.com/questions/19245883/android-launching-wrong-activity – Tom Aug 29 '15 at 21:27

2 Answers2

0

To change your default activity at launch click on the "Run" menu and select "Edit Configurations". Then change the activity from "Launch options" section: Screenshot

Aci89
  • 318
  • 5
  • 14
0

Just Clean Project and Rebuild Project

Build => Clean Project

After Cleaning

Build => Rebuild Project

Now..Run the code

Enjoy

Jan Sršeň
  • 1,045
  • 3
  • 23
  • 46