Sample code for dynamically changing app icons for Android

This article introduces how to dynamically change the app icon and share it with you, as follows:

The code implementation is as follows:

Let's briefly analyze the above code:

These two properties are used to set icons and labels

Set the name of the alias to an activity and try to be consistent with the name of an < activity >. If it is not set to an activity name, some mobile phones will have problems.

Whether to display aliases. The default is true.

Specify the activity started by the alias, which must be consistent with the name of the original starting entry activity and under the label of < activity >.

After adding the < activity alias > tag, we can set a switch on the server side for the specific startup method. When it is requested to change the desktop icon, we can close the current component component through the setcomponentenabledsetting() method provided by the packagemanager object and start the component component component corresponding to the alias. In order to quickly replace the icon, We can add the restart of the launcher application code. Name is a class name defined by ourselves. Remember to pass it to the full path, such as:

Multiple aliases can be defined for < activity alias >, and different icons can be changed dynamically at different times.

Permission settings:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>