-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple MainActivities when opening via sync notification #4975
Comments
Hm, this is bad. Does this mean that when pressing the equivalent of alt+tab, there'll be two StreetCompletes? Also, how bad is this really? When the other StreetComplete is also there, it should be inactive (i.e. no listeners etc) so it should not be using any resources. Looking at the documentation for (Edit: Grammar) |
Only when going back to SC using the notification
There is a
Maybe not that bad, because I assume it will happen very rarely (more of an issue for SCEE with the nearby quest monitor #48).
I think so too... I'll have a look whether it does what we want. |
Definitely
So the next question is whether on some devices |
I don't think changing the I would also argue that not removing all listeners when the |
I had tried a lot of flags that are supposed to help (quite sure that was including |
Oh, and currently GeoUris are not handled are only handled |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Yes, it is a different problem. I just wanted to comment on the question whether there are still active listeners when the activity is in the background and whether that is a problem at all. The problem described in this issue is caused by Android creating a new activity instance for every new intent by default. This problem should be fixable by setting one or both of the following intent flags for the notification.
The other launch modes mentioned in the comments above can also be used to fix the problem. However, they change the behavior of the app in probably undesirable ways (e.g. multiple StreetComplete tasks shown in the Android Recents screen or |
Did you try Tim's suggestion(s), @Helium314 ? If it works, it could go into v53.0 due to be released tomorrow |
The flags are supposed to go to the |
It should work if you change StreetComplete/app/src/main/java/de/westnordost/streetcomplete/data/sync/SyncNotification.kt Line 23 in c5e5ac1
But please note that |
So there is no way to avoid creating multiple instances of |
Prior to API 31, all pending intents are mutable by default. However, this default value is currently overwritten by explicitly setting the |
Thanks! Setting With |
Weird, both flags work for me as described standalone and in combination on an API 29 emulator. |
@Helium314 are you testing with SCEE or SC? Maybe there are some additional things for SCEE specifically to consider. In any case, @tapetis , you are the one with the knowledge here, maybe you could just create a PR that changes the pending intent what it should be (from a Android UX best practice point of view)? I lost track of this a bit. |
I've been seeing this with both (SC only after SCEE wasn't working as expected). Maybe it's different on API 28 again? Or maybe my system doesn't behave properly here... |
How to Reproduce
Expected Behavior
Return to home screen when pressing back button, like it happens without the steps above
Versions affected
52.0 and likely older ones
Investigating what is going on reveals that
MainActivity.onCreate
is being called when the notification is clicked, but noMainActivity
is destroyed before (this happens when pressing back button).Further,
SelectedOverlayController
gets an additionalMainMapFragment
listener when opening SC via notification.(I tried using various intent flags in
createSyncNotification
to re-use the existingMainActivity
, but wasn't able to get it working)Edit: works when using
android:launchMode="singleInstance"
, but this causes issues with StreetMeasure on some Android Versions, see Helium314#426. Though maybe that one could be avoided using some intent flags...The text was updated successfully, but these errors were encountered: