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 launch mode to singleTop #967

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

classicsc
Copy link

This fixes an issue I had when using CustomTabs for external links, likely the same as #961. When closing the browser after opening a link, I was being sent back to the app launcher, when I expected to go back to the screen in Read You where I clicked the link. After some research, I found that according to https://developer.android.com/guide/topics/manifest/activity-element#lmode, the singleInstance launch mode does not allow launching other activities into MainActivity's Task. The CustomTabs activity would launch under a new foreground task, causing Android to destroy the original MainActivity task to free resources, which led to the observed behavior.

Changing MainActivity's launch mode to singleTop allows the CustomTabs to launch in the same task, keeping MainActivity alive and enabling the back button to function as expected.

Since this change affects how intents are handled, this PR also includes an override for onNewIntent to properly handle incoming feed links, as required by the singleTop mode according to the documentation. This works better than the listener used before, where adding a feed when the app was not already open did not open the subscribe dialog, but now it does. Notifications apparently work the same as before because FLAG_ACTIVITY_NEW_TASK || FLAG_ACTIVITY_CLEAR_TASK is used in NotificationHelper's intents.

@gbakeman
Copy link

That's fantastic, thanks for making for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants