Attribute "clearTaskOnLaunch" does not work

2

What I need basically is that when the user leaves the app for A or B reason to return to take me to the Login and not the screen where he stayed.

I put the attribute clearTaskOnLaunch in true then I understand that the behavior should be that being in the activity MainActivity , Main2Activity , Main3Activity if I go to the home or change the app when returning clean the backstack and it is called the activity TimeOut who is the one who has the attribute, but this behavior does not happen and always returns to activity where it stayed.

This is my manifest, I do not know if I should configue something else to make it work:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mikemir.sessiontimeout">

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

        <service
            android:name=".Services.SessionService"
            android:enabled="true"
            android:exported="true" />

        <activity android:name=".TimeOut"
            android:clearTaskOnLaunch="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".MainActivity" />
        <activity android:name=".Main2Activity" />
        <activity android:name=".Main3Activity" />
    </application>

</manifest>
    
asked by Michael Emir 31.03.2016 в 10:35
source

1 answer

1

It's not that it does not work clearTaskOnLaunch just make sure Activities start from your root activity TimeOut .

If you check the documentation :

  

This attribute is significant only for activities that start   a new task (the root activity); is ignored for all others   homework activities.

Therefore, it should work correctly in this way, the root activity TimeOut , start the other activities:

This way it would not work correctly, since the root activity, Activity 1, does not start Activity 3:

Ensure that the intent to open the activities starts from the activity:

 <activity android:name=".TimeOut"
            android:clearTaskOnLaunch="true">
    
answered by 02.04.2016 в 06:31