owncloud / android

:phone: The ownCloud Android App
GNU General Public License v2.0
3.79k stars 3.05k forks source link

[BUG] Doubled app after installing #4262

Open jesmrec opened 8 months ago

jesmrec commented 8 months ago

Steps to reproduce

  1. Install the app from scratch
  2. Open the app

Actual behaviour

App is doubled:

https://github.com/owncloud/android/assets/14894746/757ad1fd-1224-4d61-88d7-b57d23c69e27

only happens if there is no accounts

Expected behaviour

app only once

Pixel 2, Android 11

Reproducible in v4.1.1 and so on

Aitorbp commented 7 months ago

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:

3. With SplashScreen exclude from Recents screen and FileDisplayActivity excludes too in SplashScreen:

The third option will be taken as a solution.

Aitorbp commented 6 months ago

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.

Documentation: https://developer.android.com/guide/components/activities/recents

JuancaG05 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

Open the apk directly in Android Studio and look into the given manifest ....

JuancaG05 commented 5 months ago

Can you reproduce it ? I didn't investigated.

Hi @hannesa2, yes, we can reproduce it, just as you can see in the video of the first comment.

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.

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.

jesmrec commented 5 months ago

As clue, we think this one could be a solution: https://github.com/owncloud/android/issues/3391, but it has more issues to take in account (MDM regards).

hannesa2 commented 5 months ago

I checkout out latest master and I only see one ownCloud.

image

Sorry, it's a local issue on your side

JuancaG05 commented 5 months ago

Hi @hannesa2, as I commented, there is only a single icon on our side as well, so that is NOT the problem. The problem can be seen in the Recents screen (pressing the square button from the device's bottom bar in case of Pixels, as shown in the video in https://github.com/owncloud/android/issues/4262#issue-2043089936), where there are 2 different elements for ownCloud, when there should be just 1.

Aitorbp commented 5 months ago

I have try to implement SplashScreenApi to see if the splash screen is excluded from recents. But It isn't changed the behaviour. Unfortunately, the splash screen is showing in the Recents Apps.