简体   繁体   English

每次单击主屏幕上的应用程序图标时,启动应用程序启动屏幕

[英]launch a app splash screen everytime we click a app icon from home screen

What is happening: 怎么了:

  • Currently when i click the app icon for the first time i am loading SplashActivity and then loading ActAtomicGodDetailDesc 当前,当我第一次单击应用程序图标时,我正在加载SplashActivity ,然后加载ActAtomicGodDetailDesc
  • Now when i minimize the app -- > then go to home screen -- > then click on the app icon again ActAtomicGodDetailDesc is displaying instead of SplashActivity 现在,当我尽量减少应用程序- >然后进入主屏幕- >然后点击应用程序图标再次ActAtomicGodDetailDesc的,而不是显示的SplashActivity

What i want: 我想要的是:

Everytime i want the app to fire SplashActivity when i click the app icon from the home screen 每次我希望从主屏幕上单击应用程序图标时触发该应用程序启动SplashActivity

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 有任何想法吗

Everytime i want the app to fire SplashActivity when i click the app icon from the home screen 每次我希望从主屏幕上单击应用程序图标时触发该应用程序启动SplashActivity

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. 我认为您需要在Splash Activity上设置android:clearTaskOnLaunch="true" ,这样,每当您单击应用程序图标时,它将作为root活动启动。

android:clearTaskOnLaunch http://developer.android.com/guide/topics/manifest/activity-element.html#clear 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. 每当从主屏幕重新启动时,是否将除根活动之外的所有活动都从任务中删除,如果始终将任务剥离到其根活动,则为“ true”,否则为“ false” 。 The default value is "false". 默认值为“ 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. 当值为“ true”时,无论用户上次在任务中执行什么操作以及是否使用“上一步”或“主页”按钮将其保留,用户每次都再次启动任务时,都会进入其根活动。 When the value is "false", the task may be cleared of activities in some situations (see the alwaysRetainTaskState attribute), but not always. 当值为“ false”时,在某些情况下可以清除任务中的活动(请参阅alwaysRetainTaskState属性),但并非总是如此。

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. 例如,假设某人从主屏幕启动活动P,然后从那里转到活动Q。用户接下来按Home,然后返回到活动P。通常,用户将看到活动Q,因为这就是他们的活动。在P的任务中最后一次做。 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. 但是,如果P将此标志设置为“ true”,则当用户按下Home键并将任务转到后台时,位于其顶部的所有活动(在本例中为Q)都将被删除。 So the user sees only P when returning to the task. 因此,用户在返回任务时只能看到P。

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; 如果此属性和allowTaskReparenting均为“ true”,则任何可以重新建立父级的活动都将移至与它们共享相似性的任务; 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> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 主屏幕点击事件上的应用程序图标 - app icon on click event from home screen 将应用启动图标添加到主屏幕 - Adding app launch icon to the home screen 如果应用程序已登录且在后台,然后单击主屏幕上的应用程序启动器图标,它将显示登录屏幕 - if app is login and its in background and click on app launcher icon from home screen it will display login screen 每次我点击主屏幕图标时,我的应用程序都会显示启动画面,而应用程序在后台 - My app show splash screen every time i tap home screen icon while app in background 如何使应用程序图标在启动画面中居中? - How to center the app icon in splash screen? 如何检查活动是从通知启动还是从用户单击 android 中的主屏幕仪表板应用程序图标启动 - how to check whether the activity was launched from notification or from the user click on home screen dashboard app icon in android 在启动屏幕出现之前,使用AppCompatActivity暂停应用启动以预览屏幕 - Pause on App Launch with AppCompatActivity for preview screen before splash screen appears 从App2启动App1,然后按主屏幕按钮到主屏幕,然后通过按图标再次打开App1,为什么onCreate被调用? - Launch App1 from App2,then press home button to the home screen,and open App1 again by press icon,why onCreate get called? 如果以前是从应用程序屏幕启动的,则从主屏幕启动应用程序将在现有实例的顶部启动它,反之亦然 - Launching app from home screen will launch it on top of an existing instance if it was launched previously from the app screen, vise versa 如何直接从启动画面直接启动您的 android 应用程序,而不显示主屏幕? - How to directly boot your android app straight from splash screen, without showing the home screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM