gpt4 book ai didi

android - 每次我们从主屏幕单击应用程序图标时都会启动一个应用程序启动画面

转载 作者:行者123 更新时间:2023-11-29 15:54:56 24 4
gpt4 key购买 nike

发生了什么:

  • 目前,当我第一次点击应用程序图标时,我正在加载SplashActivity 然后加载 ActAtomicGodDetailDesc
  • 现在,当我最小化应用程序时 --> 然后转到主屏幕 --> 然后再次单击应用程序图标 ActAtomicGodDetailDesc 正在显示而不是 SplashActivity

我想要什么:

每次我希望应用程序在我从主屏幕单击应用程序图标时触发 SplashActivity

list

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

如何实现?任何想法

最佳答案

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

我认为您需要在 Splash Activity 上设置 android:clearTaskOnLaunch="true",这样无论何时您点击应用程序图标,它都会作为根 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>

关于android - 每次我们从主屏幕单击应用程序图标时都会启动一个应用程序启动画面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28656037/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com