Skip to content
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

Change launchMode on MainActivity from "singleTop" to "singleTask" #3126

Closed
wants to merge 1 commit into from

Conversation

hamorillo
Copy link
Contributor

@hamorillo hamorillo commented Oct 29, 2024

Description

Looking at the Android documentation, it seems like the singleTask launchMode is more correct to the Gravatar's MainActivity.

"singleTask"
The system creates the activity at the root of a new task or locates the activity on an existing task with the same affinity. If an instance of the activity already exists, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Meanwhile all of the other activities on top of it are destroyed.

vs

"singleTop"
If an instance of the activity already exists at the top of the current task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity. The activity is instantiated multiple times, each instance can belong to different tasks, and one task can have multiple instances (but only if the activity at the top of the back stack is not an existing instance of the activity).

Despite being just a one-line change, please smoke test everything that comes to your mind related to how the activity is launched. I've done the same, but I have limited knowledge of the code base.

cc: @MiSikora

Testing Instructions

  • Smoke test the app. Test deep links, close the app, and do everything you can about how the activity is launched.

Checklist

- [ ] If this is a user-facing change, I have added an entry in CHANGELOG.md
- [] Ensure the linter passes (./gradlew spotlessApply to automatically apply formatting/linting)
- [ ] I have considered whether it makes sense to add tests for my changes
- [ ] All strings that need to be localized are in modules/services/localization/src/main/res/values/strings.xml
- [ ] Any jetpack compose components I added or changed are covered by compose previews
- [ ] I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

I have tested any UI changes...

- [ ] with different themes
- [ ] with a landscape orientation
- [ ] with the device set to have a large display and font size
- [ ] for accessibility with TalkBack

singleTask looks a more correct launchMode for the MainActivity
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 29, 2024

📲 You can test the changes from this Pull Request in 📱 Mobile by scanning the QR code below to install the corresponding build.
App Name 📱 Mobile
Build TypedebugProd
Commitf317732
Direct Downloadpocketcasts-app-prototype-build-pr3126-f317732.apk
📲 You can test the changes from this Pull Request in 🚗 Automotive by scanning the QR code below to install the corresponding build.
App Name 🚗 Automotive
Build TypedebugProd
Commitf317732
Direct Downloadpocketcasts-automotive-prototype-build-pr3126-f317732.apk
📲 You can test the changes from this Pull Request in ⌚ Wear by scanning the QR code below to install the corresponding build.
App Name ⌚ Wear
Build TypedebugProd
Commitf317732
Direct Downloadpocketcasts-wear-prototype-build-pr3126-f317732.apk

@hamorillo hamorillo added this to the 7.77 milestone Oct 29, 2024
@hamorillo hamorillo added the [Type] Enhancement Improve an existing feature. label Oct 29, 2024
@hamorillo hamorillo marked this pull request as ready for review October 29, 2024 16:11
@hamorillo hamorillo requested a review from a team as a code owner October 29, 2024 16:11
@hamorillo hamorillo requested review from MiSikora and removed request for a team October 29, 2024 16:11
Copy link
Contributor

@MiSikora MiSikora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this breaks the app. When a different activity is on top minimizing the app and then opening the app again collapses the activity stack to the MainActivity. In the attached video you can see that. The Upsell screen disappears after I reopen the active application either by tapping on the app's icon, on a widget, or on a media notification. This happens with other activities as well.

screen-20241030-083226.mp4

@hamorillo
Copy link
Contributor Author

hamorillo commented Oct 30, 2024

Thanks for the testing @MiSikora!

I've been reading, and investigating about that. It seems to be the expected behavior when using the singleTask in the Main activity. There are some threads on Stackoverflow like this where they mentioned that, despite not being clearly explained in the documentation that's how it works.

Some people suggest some workarounds that consist of not using the singleTask mode for the Main Activity.

Said that, I think we shouldn't move forward with this change. PocketCast is working well and create a new activity with the suggested workarounds just to change the launch mode of the MainActivity doesn't make sense. If you agree, I'll close this PR.

@MiSikora
Copy link
Contributor

Yes, I agree we shouldn't merge it when it results in this behavior. Honestly the only real solution that I know of is using a single activity but this is not currently feasible.

@hamorillo
Copy link
Contributor Author

Anyway, thanks for you help @MiSikora!

@hamorillo hamorillo closed this Oct 30, 2024
@hamorillo hamorillo deleted the hamorillo/main-activity-launch-mode branch October 30, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement Improve an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants