Devrath
Devrath

Reputation: 42834

launch a app splash screen everytime we click a app icon from home screen

What is happening:

What i want:

Everytime i want the app to fire SplashActivity when i click the app icon from the home screen

manifest

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".SplashActivity"
            android:label="@string/app_name"
            android:noHistory="true"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>     
        <activity
            android:name=".ActAtomicGodDetailDesc"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
    </application>

How to achieve this ? any ideas

Upvotes: 2

Views: 3732

Answers (1)

Ajay S
Ajay S

Reputation: 48602

Everytime i want the app to fire SplashActivity when i click the app icon from the home screen

I think you require to set android:clearTaskOnLaunch="true" on Splash Activity such that whenever you click on app icon then it will start as root activity.

android:clearTaskOnLaunch http://developer.android.com/guide/topics/manifest/activity-element.html#clear

Whether or not all activities will be removed from the task, except for the root activity, whenever it is re-launched from the home screen — "true" if the task is always stripped down to its root activity, and "false" if not. The default value is "false". This attribute is meaningful only for activities that start a new task (the root activity); it's ignored for all other activities in the task. When the value is "true", every time users start the task again, they are brought to its root activity regardless of what they were last doing in the task and regardless of whether they used the Back or Home button to leave it. When the value is "false", the task may be cleared of activities in some situations (see the alwaysRetainTaskState attribute), but not always.

Suppose, for example, that someone launches activity P from the home screen, and from there goes to activity Q. The user next presses Home, and then returns to activity P. Normally, the user would see activity Q, since that is what they were last doing in P's task. However, if P set this flag to "true", all of the activities on top of it (Q in this case) were removed when the user pressed Home and the task went to the background. So the user sees only P when returning to the task.

If this attribute and allowTaskReparenting are both "true", any activities that can be re-parented are moved to the task they share an affinity with; the remaining activities are then dropped, as described above.

<activity
    android:name=".SplashActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait" 
    android:clearTaskOnLaunch="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

Upvotes: 5

Related Questions