Skip to content

fix: prevent app from closing when changing icon on android - #80

Open
vsteenhoudt wants to merge 1 commit into
capacitor-community:mainfrom
vsteenhoudt:prevent-app-closing-on-android
Open

fix: prevent app from closing when changing icon on android#80
vsteenhoudt wants to merge 1 commit into
capacitor-community:mainfrom
vsteenhoudt:prevent-app-closing-on-android

Conversation

@vsteenhoudt

Copy link
Copy Markdown

Disabling the currently enabled alias will prevent the DONT_KILL_APP flag from working.

This will allow the change of the icon without the app closing on android.

@vsteenhoudt

Copy link
Copy Markdown
Author

@johnborges
We were having an issue that switching the icon on android also cause the app to close.
We also experienced this with the example provided in this repo.
This should fix this and allow the user to change the app icon without closing the app.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the Android icon-switching logic to avoid disabling MainActivity during an icon change, which can cause the app process to be killed even when using PackageManager.DONT_KILL_APP. This aligns better with the documented Android setup where launcher entry points are handled via activity-alias.

Changes:

  • Removed the setComponentEnabledSetting(... MainActivity ..., DISABLED, DONT_KILL_APP) call from change().
  • Added an explanatory comment indicating why MainActivity should not be disabled during runtime icon switching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +76 to +77
// Do not disable main app icon
// DONT_KILL_APP will not work if we disable the currently enabled alias at runtime
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