skb1129 / react-native-change-icon

Change your application icon programmatically for React Native apps
MIT License
500 stars 92 forks source link

Android refactor to handle activities not named "Main" #100

Open sidferreira opened 10 months ago

sidferreira commented 10 months ago

I had a specific need where the Activity running the icon change was not the one that launched the app. This change tries to allow LaunchActivity to be the Launcher and MainActivity to be the one running the show.

Part of the trick is to use the code below to find the current launch activity:

Intent intent = packageManager.getLaunchIntentForPackage(packageName);
_currentLaunchClassName = intent.resolveActivity(packageManager).getClassName();

I played a lot with the code, renamed some variables to add clarification, and tried to make it more flexible.

My goal was to avoid killing the app when changing the icon, but I'm still tweaking this part.

It seems that there were some changes in the code after the latest release, so extra caution is needed reviewing that.

sidferreira commented 9 months ago

@skb1129 @haydncomley I'll try to spend some time reducing the difference from my code to main this week

pwltr commented 5 months ago

I'm running this PR branch on my app and it works, seems to fix #74 and #106

sidferreira commented 4 months ago

@skb1129 anything I can do to help with this review?