1
votes

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.

3
Try removing the <intent-filter> for your MainActivity.Andro Selva
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
@paulsmith - i am having same issue now. App doesn't run automatically on my phone. Have you found any fix for it?Anjum

3 Answers

0
votes

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..

0
votes

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>

0
votes

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...................