简体   繁体   中英

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. Remove android:launchMode="singleTask" for more about singletask

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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