programmatically-changing-app-icon/ #25
Replies: 3 comments 3 replies
-
Hey there, Jake. Thanks for writing this up. It's amazingly helpful. What if the original Example: <activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- deep link and push notification intent filter -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="deeplinkandpushnotification.provider.com" />
</intent-filter>
<!-- firebase cloud messaging intent filter -->
<intent-filter>
<action android:name="fcm.ACTION.HELLO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> Where do they need to go? Is it essential that we clone those <activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity-alias
android:icon="@mipmap/icon_red"
...>
<!-- launcher intent filter -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- deep link and push notification intent filter -->
<!-- firebase cloud messaging intent filter -->
</activity-alias>
<activity-alias
android:icon="@mipmap/icon_green"
...>
<!-- launcher intent filter -->
<!-- deep link and push notification intent filter -->
<!-- firebase cloud messaging intent filter -->
</activity-alias>
<activity-alias
android:icon="@mipmap/icon_blue"
...>
<!-- launcher intent filter -->
<!-- deep link and push notification intent filter -->
<!-- firebase cloud messaging intent filter -->
</activity-alias> I've had folks at work run up to me saying that not having copies of each I did attempt to only add exactly the necessary |
Beta Was this translation helpful? Give feedback.
-
I found a way to work around this while in development. You can simply edit the launch configuration of the app using Run/Debug Configurations (Android Studio > Run > Edit Configurations...) and the IDE will launch it again using the designated At the Run/Debug Configurations, select the launch configuration of your project (I assume
Setting it back is easy when you switch back to the default icon. Just do:
I assume that your project is configured to ignore these changes from commits. Otherwise, I'd highly recommend it in order to not mess the original configuration up! |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for the explanation. When I change the icon, app will be killed by the system. I mean PackageManager.DONT_KILL_APP is not working. Is there a way to prevent that? |
Beta Was this translation helpful? Give feedback.
-
programmatically-changing-app-icon/
In Android, your app’s icon is a crucial part of your project. It’s what grabs the user’s attention first, identifies your app amongst the sea of competitors, and is the most important piece of visual branding. However, usually this icon is defined in your manifest, then never changes except through update.
https://blog.jakelee.co.uk/programmatically-changing-app-icon/
Beta Was this translation helpful? Give feedback.
All reactions