简体   繁体   English

单击应用程序图标时,应用程序重新启动

[英]App relaunch when clicking on application icon

I have the following manifest: 我有以下清单:

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

    <activity
            android:name=".LoginActivity" android:launchMode="singleTask" 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=".MainActivity" android:screenOrientation="portrait"/>
    <activity android:name=".TaskDetailActivity" android:screenOrientation="portrait"/>
    <activity android:name=".ConfigurationActivity" android:screenOrientation="portrait"/>

</application>

I don't know why, if I minimize the application and then i click on application icon, the app get relaunched instead of going to the last activity. 我不知道为什么,如果我最小化应用程序,然后单击应用程序图标,该应用程序将重新启动,而不是转到上一个活动。

If I use application switcher instead of application icon for opening the application, It goes back to the last activity on use, so it works as expected. 如果我使用应用程序切换器而不是应用程序图标打开应用程序,它将返回到上一次使用的活动,因此它可以按预期工作。

Why is this behavior? 为什么会这样呢? I want to open the last activity when I click on application icon not restart the whole application. 当我单击应用程序图标而不重新启动整个应用程序时,我想打开上一个活动。

An Activity with singleTask launchMode is allowed to have only one instance in the system. 具有singleTask launchMode的Activity只能在系统中有一个实例。 Remove android:launchMode="singleTask" for more about singletask 删除android:launchMode="singleTask"以获取更多有关单任务的信息

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM