gpt4 book ai didi

android - 了解安卓 :launchMode

转载 作者:搜寻专家 更新时间:2023-11-01 08:52:23 25 4
gpt4 key购买 nike

我对 Android 中不同的 Activity 启动模式感到非常困惑。我知道它与 Activity 堆栈有关,这对我来说也不太清楚。如果能通过简单的用例对每个启动模式进行简短说明,我将不胜感激。

最佳答案

SingleTask and SingleInstance activities can only begin a task. They are always at the 
root of the activity stack. Moreover, the device can hold only one instance of the
activity at a time — only one such task.

More Details

<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".Standard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<activity
android:name=".SingleTop"
android:launchMode="singleTop" />

<activity
android:name=".SingleTask"
android:launchMode="singleTask"
android:taskAffinity="" />

<activity
android:name=".SingleInstance"
android:launchMode="singleInstance" /> <!--//TODO launchMode -->

</application>

<uses-permission android:name="android.permission.GET_TASKS" />

Sample Demo

关于android - 了解安卓 :launchMode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21980641/

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