Redeem Now
Read More
Read now

Change Launcher icon dynamically in Android

Save

Change Launcher icon dynamically in Android! What is it mean? Well, let’s discuss it. In the mobile application, we can say the launcher icon is the unique identification of that app. The launcher icon is self-sufficient to define the type of application. Normally a single app consists of a single launcher icon. But how we will manage, when we have to change or update the launcher icon on runtime according to different scenarios. Or when we try to change the launcher icon dynamically.

In this blog, we will learn how we can change or update the launcher icon dynamically or on runtime. For this, we will follow the mentioned steps:

 

In this step, we will create an empty class for each launcher icon that we want to change on runtime. This is class is an empty class, which consists of nothing in its body. I have created two empty classes for the two launcher icon, you can create any number of them as per the requirement.

For the first launcher icon:

And for the second launcher icon:

Use Activity alias in the manifest file

Activity alias represents the symbolic link (Symlink) to an activity. It is the most unused tag in the android manifest.

Note:

  1. If you are using any deep links inside the app, then please put them in all the activity alias.
  2. Only one activity alias should be enabled initially, otherwise, it will create multiple launcher icon at the time time of app launching.
  3. Should enable the default activity alias which we want to show on the first time of app launching.
  4. If you want a different name with each launcher icon then you can also change the label name in each activity alias.

 

Now, the final steps (Enable and disable the activity alias for the respective launcher icons)

After all the steps, we can now enable or disable the activity alias according to your requirement. In this demo, we are performing on the splash screen launching, with the help of shared pref. You can do it on this button click event or any other event.

At a time one activity alias should be enabled and all others should be disabled. For enabling the first launcher we do the following code:

 

For enabling a second launcher icon, we do the following code.

 

I hope, this blog is helpful for you to Change the Launcher icon dynamically in Android

Please refer to my previous blog for apple login in android: Apple login in android with Firebase

Also, check the following link: Activity alias in android

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close