1

I'm not really sure what's going on, but for some reason my SplashActivity is not being created on launch, even though I put the MAIN and LAUNCHER intent for it. Here's my manifest:

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

    <activity
        android:name=".SplashActivity"
        android:label="@string/title_activity_main"
        android:theme="@style/Theme.Splash" >
        <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="whatever" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

</application>

If I remove the second activity, then my SplashActivity is launched. But for some reason when the MainActivity is included, the Splash is ignored. Is it possible that having the activity name be MainActivity overrides whatever you set for your Launcher activity?

Update:

It seems everybody is suggesting something that I had already tried before posting this question so I think it's better I mention it now before more people post the same suggestion :)

Unfortunately removing the intent on the MainActivity results in the following in my Console output:

[2012-10-11 22:58:44 - Test] ------------------------------
[2012-10-11 22:58:44 - Test] Android Launch!
[2012-10-11 22:58:44 - Test] adb is running normally.
[2012-10-11 22:58:44 - Test] Performing com.test.test.MainActivity activity launch
[2012-10-11 22:58:44 - Test] Automatic Target Mode: using device '9a03c386'
[2012-10-11 22:58:45 - Test] Application already deployed. No need to reinstall.
[2012-10-11 22:58:45 - Test] Starting activity com.test.test.MainActivity on device 9a03c386
[2012-10-11 22:58:45 - Test] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.test.test/.MainActivity }
[2012-10-11 22:58:45 - Test] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.test.test/.MainActivity } from null (pid=12510, uid=2000) not exported from uid 10132
[2012-10-11 22:58:45 - Test] ActivityManager: at android.os.Parcel.readException(Parcel.java:1327)
[2012-10-11 22:58:45 - Test] ActivityManager: at android.os.Parcel.readException(Parcel.java:1281)
[2012-10-11 22:58:45 - Test] ActivityManager: at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1728)
[2012-10-11 22:58:45 - Test] ActivityManager: at com.android.commands.am.Am.runStart(Am.java:433)
[2012-10-11 22:58:45 - Test] ActivityManager: at com.android.commands.am.Am.run(Am.java:107)
[2012-10-11 22:58:45 - Test] ActivityManager: at com.android.commands.am.Am.main(Am.java:80)
[2012-10-11 22:58:45 - Test] ActivityManager: at com.android.internal.os.RuntimeInit.finishInit(Native Method)
[2012-10-11 22:58:45 - Test] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:263)
[2012-10-11 22:58:45 - Test] ActivityManager: at dalvik.system.NativeStart.main(Native Method)

Don't know what it means, but I have to assume it's some kind of error.

paul smith
  • 1,327
  • 4
  • 17
  • 32
  • 2
    Try removing the for your MainActivity. – Andro Selva Oct 12 '12 at 05:57
  • Your suggestion works, but there seems to be another issue that is a result of this. Now the program doesn't automatically start on my phone when I try to run it from Eclipse, instead Eclipse just installs it and does nothing else. I have to manually run the program myself on my phone every time. But if I leave my Manifest the way it was before, then my program automatically launches when I run it from Eclipse. What is causing this new issue? Do I need to add something else to the Manifest? – paul smith Oct 12 '12 at 15:26
  • @paulsmith - i am having same issue now. App doesn't run automatically on my phone. Have you found any fix for it? – Anjum Dec 31 '15 at 08:23

3 Answers3

0

try this

<activity
    android:name=".SplashActivity"
    android:label="@string/title_activity_main"
    android:theme="@style/Theme.Splash" >
    <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="whatever" >

</activity>

Naveen Kumar
  • 3,738
  • 4
  • 29
  • 50
0

The section

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

is used to let android know which activity to start when application starts.. Since you wrote it inside both of your activity, android takes second one as the starting activity.. So remove that line from .MainActivity block..

<activity
    android:name=".SplashActivity"
    android:label="@string/title_activity_main"
    android:theme="@style/Theme.Splash" >
    <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="whatever" >
</activity>

After Seeing OP's edit

Have you seen this? Also after changing AndroidManifest.xml file, delete and reinstall the app once..

Community
  • 1
  • 1
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
  • By the way, I have noticed that when I do this, the app doesn't automatically launch on my phone when I press the run button in Eclipse. It just installs it on my device and then I have to manually launch the program on my phone. Why is that? It has to be related to this change because if I leave it as it was before, the program automatically launches on my phone when I run it from Eclipse. – paul smith Oct 12 '12 at 15:23
0

try this :

    <activity 
        android:name="SplashScreen"
        android:theme="@style/Theme.Transparent"    
        android:screenOrientation="landscape"       
    >
        <intent-filter>
            <action android:name="android.intent.action.MAIN"></action>
            <category android:name="android.intent.category.LAUNCHER"></category>
        </intent-filter>
    </activity>

and give me review...................

Akash
  • 206
  • 1
  • 4