1

I have 2 activities, 'Splash'and 'StartingPoint'. My XML EXPLICITLY states that 'Splash' is the Activity with MAIN and LAUNCHER, however when running the app, 'StartingPoint' always seems to be the first thing running. How can I fix it?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.commer.commest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

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

        <activity android:name="com.commer.commest.Splash" 
                  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="com.commer.commest.StartingPoint" 
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.commer.commest.STARTINGPOINT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>
user2651348
  • 21
  • 1
  • 3
  • accepted answer doesn't show how you finally solved it, rather, comment in the accepted answer is mentioning the solution. if none of the answers have correct solution, you should add your own and then mark it as accepted. – sandeepd Oct 13 '22 at 10:37

9 Answers9

2

Faced similar issue,
in my case the culprit was

android:launchMode="singleInstance"

I had to remove this from Splash to launch it everytime.

    <activity
        android:name=".features.splash.SplashActivity"
        android:launchMode="singleInstance"  // had to remove this
        android:screenOrientation="portrait"
        android:theme="@style/SplashTheme"
        android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

    <activity
        android:name=".features.login.LoginActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" />
Prabs
  • 4,923
  • 6
  • 38
  • 59
1

Update like :

<activity android:name="com.commer.commest.StartingPoint" 
                  android:label="@string/app_name">
        </activity>

instead of

<activity android:name="com.commer.commest.StartingPoint" 
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.commer.commest.STARTINGPOINT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
0
        <intent-filter>
            <action android:name="com.commer.commest.STARTINGPOINT" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

Remove these lines. Your problem solved

Actually you make this application as default launcher application no need to write it

enjoy

Shankar
  • 518
  • 5
  • 16
0

can you try changing the activity android:name to .Splash only, as well as to your starting point.

<activity android:name=".Splash"

<activity android:name=".StartingPoint"
0

you should change this:

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

    <activity android:name="com.commer.commest.Splash" 
              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="com.commer.commest.StartingPoint"/> 


</application>
Piyush
  • 18,895
  • 5
  • 32
  • 63
  • I did the changes and removed the element, but the 'StartingPoint' Activity is still running first. ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.commer.commest/.StartingPoint } – user2651348 Aug 24 '13 at 06:53
  • Yes, when I remove the StartingPoint Activity completely, the Splash becomes the first Activity, but when I put it back it goes back to the way it was – user2651348 Aug 24 '13 at 07:06
  • have you use this one?? – Piyush Aug 24 '13 at 07:07
  • Yes, I tried that too, the StartingPoint Activity keeps being the first Activity to appear – user2651348 Aug 24 '13 at 07:09
  • Ok..Just check if your activity name is Splash?? – Piyush Aug 24 '13 at 07:19
  • 1
    Hey Piyush, I realized my error... I had the run configurations of my avd set to the StartingPoint Activity! Sorry for all the confusion I may have been giving you. I appreciate all the help you and everyone here has been offering! – user2651348 Aug 24 '13 at 07:20
0

You've added default category in com.commer.commest.STARTINGPOINT activity thats why you are facing this problem. Remove the intent filter from the activity com.commer.commest.STARTINGPOINT. Why you are adding DEFAULT category here? If you want yo know about use of default category follow the link here

In short if you added CATEGORY_DEFAULT to an activity it will become the default activity for application context. So whenever Context.startActivity() called, your default activity will be stated.

Enjoy coding!!

Community
  • 1
  • 1
Jatin Malwal
  • 5,133
  • 2
  • 23
  • 26
0

As the name suggests, the DEFAULT category(intent filter), is used to declare some operation as default action. For example if you want a particular activity to be opened while opening the app. You implement this in your manifest:

        <intent-filter>
            <action android:name="package name" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

try removing the intent filters from you code under the package name "com.commer.commest.StartingPoint". Like so:

<activity android:name="com.commer.commest.StartingPoint" 
          android:label="@string/app_name">
</activity>
Sathya
  • 678
  • 4
  • 12
0

You should check the run configurations as suggested on following thread: https://stackoverflow.com/a/19311925/2219924

I had the EXACT same problem and also tried everything suggested here with no luck. It's Eclipse itself that's being the pain in the butt...

Community
  • 1
  • 1
NealRaven
  • 11
  • 1
  • 1
  • 4
0

After spending the time found the issue in configuration level.

You can get the Android Studio not to complain by going to the "Edit Configurations" menu (tap "Shift" three times, type "Edit Configurations"), then change Launch Options > Launch to "Nothing".

I'll probably add a generic activity containing instructions.

Aman Jham
  • 478
  • 6
  • 18