You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have to try to handle which activities are going to be shown in the Recents Screen. To prevent this, We must use android:excludeFromRecents manually so that the system does not open activities in Recent automatically. To give more context: Normally, we let the system define how our tasks and activities are represented in the Recents screen. We don't need to modify this behavior. However, your app can determine how and when activities appear in the Recents screen.
In our case, I don't see any behavior that directly handles the SplashActivity, which is the screen that remains open in Recent Apps. Following the documentation, the system is doing it internally. By default, a document task automatically exits from the Recents screen when its activity finishes. It is what is happening with SplashActivity.
But this solution does not work when the application is installed from scratch. Since three screens appear in Recent Apps SplashScreen, FileDisplayActivity and LoginActivity. So at this point we also have to delete this task manually.
Below I show you the following scenarios:
1. Without changes:
Screens in Recents screen when opening app from scratch:
SplashActivity
FileDisplayActivity
LoginActivity
Screen in Recents screen when opening app
SplashActivity
LoginActivity
2. With SplashScreen exclude from Recents screen:
Screens in Recents screen when opening app from scratch:
FileDisplayActivity
LoginActivity
Screens in Recents screen when opening app: LoginActivity
3. With SplashScreen exclude from Recents screen and FileDisplayActivity excludes too in SplashScreen:
Screens in Recents screen when opening app from scratch: LoginActivity
Screens in Recents screen when opening app: LoginActivity
We are facing a problem with task management in the Recents Screen. By adding android:excludeFromRecents="true"
in the SplashScreen the behaviour of the application is not as expected. That is to say, if we are in the Recents Screen and we find a task from onwCloud and another from another application, when we open this second application, the ownCloud application will close from Recents.
To avoid this we have tried different formulas, from some conventional ones playing with the flags to manually delete the tasks we don't want and leave only the LoginActivity task, but the application is still closed.
The ideal option, following the documentation, would be to leave android:excludeFromRecents="true" in the Manifest and when we make the intent to LoginActivity add the following tags: FLAG_ACTIVITY_MULTIPLE_TASK and FLAG_ACTIVITY_RETAIN_IN_RECENTS. FLAG_ACTIVITY_MULTIPLE_TASK: If you set this flag, when creating a new document, the system will always create a new task with the target activity as root. This setting allows to open the same document in several tasks. FLAG_ACTIVITY_RETAIN_IN_RECENTS: If you want to retain a task in the Recent screen, even if the activity is already finished, pass this flag to the addFlags() method of the intent that starts the activity.
This method did not work.
Similarly, the FLAG_ACTIVITY_NEW_DOCUMENT tag was also used, but this did not work either.
The use of the android:documentLaunchMode and android:launchMode tags and its various properties has also been managed. We have tried to follow some logic of the app to set these tags, but they did not give the expected result either.
Hi @hannesa2, we would like to know if you have any ideas regarding this issue? We were trying several stuff as you can see in previous comments, but we didn't get to a valid solution. Any suggestions are welcome 😄
It's not that we have several icons for the app, the title of the issue may be misleading. The problem here is that when the app is opened (with the single icon we have for it), we have like 2 instances of the app because 2 different activities appear in the Recents screen, and we expect just 1.
Activity
Aitorbp commentedon Jan 16, 2024
We have to try to handle which activities are going to be shown in the Recents Screen. To prevent this, We must use android:excludeFromRecents manually so that the system does not open activities in Recent automatically. To give more context: Normally, we let the system define how our tasks and activities are represented in the Recents screen. We don't need to modify this behavior. However, your app can determine how and when activities appear in the Recents screen.
In our case, I don't see any behavior that directly handles the SplashActivity, which is the screen that remains open in Recent Apps. Following the documentation, the system is doing it internally. By default, a document task automatically exits from the Recents screen when its activity finishes. It is what is happening with SplashActivity.
But this solution does not work when the application is installed from scratch. Since three screens appear in Recent Apps SplashScreen, FileDisplayActivity and LoginActivity. So at this point we also have to delete this task manually.
Below I show you the following scenarios:
1. Without changes:
2. With SplashScreen exclude from Recents screen:
LoginActivity
3. With SplashScreen exclude from Recents screen and FileDisplayActivity excludes too in SplashScreen:
LoginActivity
LoginActivity
The third option will be taken as a solution.
Aitorbp commentedon Feb 7, 2024
We are facing a problem with task management in the Recents Screen. By adding
android:excludeFromRecents="true"
in the
SplashScreen
the behaviour of the application is not as expected. That is to say, if we are in the Recents Screen and we find a task from onwCloud and another from another application, when we open this second application, the ownCloud application will close from Recents.To avoid this we have tried different formulas, from some conventional ones playing with the flags to manually delete the tasks we don't want and leave only the
LoginActivity
task, but the application is still closed.The ideal option, following the documentation, would be to leave
android:excludeFromRecents="true"
in theManifest
and when we make the intent to LoginActivity add the following tags:FLAG_ACTIVITY_MULTIPLE_TASK
andFLAG_ACTIVITY_RETAIN_IN_RECENTS
.FLAG_ACTIVITY_MULTIPLE_TASK
: If you set this flag, when creating a new document, the system will always create a new task with the target activity as root. This setting allows to open the same document in several tasks.FLAG_ACTIVITY_RETAIN_IN_RECENTS
: If you want to retain a task in the Recent screen, even if the activity is already finished, pass this flag to the addFlags() method of the intent that starts the activity.This method did not work.
Similarly, the
FLAG_ACTIVITY_NEW_DOCUMENT
tag was also used, but this did not work either.The use of the
android:documentLaunchMode
andandroid:launchMode
tags and its various properties has also been managed. We have tried to follow some logic of the app to set these tags, but they did not give the expected result either.Documentation: https://developer.android.com/guide/components/activities/recents
JuancaG05 commentedon Mar 1, 2024
Hi @hannesa2, we would like to know if you have any ideas regarding this issue? We were trying several stuff as you can see in previous comments, but we didn't get to a valid solution. Any suggestions are welcome 😄
hannesa2 commentedon Mar 1, 2024
Can you reproduce it ? I didn't investigated.
With this https://github.com/owncloud/android/blob/master/owncloudApp/src/main/AndroidManifest.xml#L82 you see an icon in launcher, and having more then one, you would see more.
This would be my first shot when I would investigate it.
hannesa2 commentedon Mar 1, 2024
Open the apk directly in Android Studio and look into the given manifest ....
JuancaG05 commentedon Mar 4, 2024
Hi @hannesa2, yes, we can reproduce it, just as you can see in the video of the first comment.
It's not that we have several icons for the app, the title of the issue may be misleading. The problem here is that when the app is opened (with the single icon we have for it), we have like 2 instances of the app because 2 different activities appear in the Recents screen, and we expect just 1.
10 remaining items