Dynamically change application icons Product: Can we dynamically change the App Icon in the Launcher? Development: No Product: Can we dynamically change the App Icon in the Launcher? Development: No Product: Can we dynamically change the App Icon in the Launcher? Development: No Product: Can we dynamically change the App Icon in the Launcher? Development: Let me think... Principle 1 — activity-alias In AndroidMainifest, there are two properties:
In addition, there is an activity-alias attribute, which can be used to create multiple different entrances. I believe that developers who have developed system settings and launchers should have seen a lot of them in the system source code. Principle 2——PM.setComponentEnabledSetting PackageManager is a general class that can manage all system components. Of course, if you root your device, you can also manage all components of other apps. Some system optimization tools disable some background services in this way. It is very easy to use:
According to the two flags PackageManager.COMPONENT_ENABLED_STATE_ENABLED and PackageManager.COMPONENT_ENABLED_STATE_DISABLED and the corresponding ComponentName, you can control whether a component is enabled. Dynamic Icon Change With the above two principles, the only thing left to achieve dynamic icon replacement is the idea. First, we create an Activity as the default entry with a default picture, then create an activity-alias for Double 11, pointing to the default Activity with a Double 11 picture, then create an activity-alias for Double 12, pointing to the default Activity with a Double 12 picture... and so on.
Wait, there is a problem with this, that is, this will display 3 entrances on the Launcher, so by default we will disable these activity-aliases first, and then enable them when they are needed. It takes a long time to train an army.
OK, after disabling the default Activity, enable the Double 11 activity-alias, the result remains unchanged and still points to the default Activity, but the icon has changed. Depending on the ROM, after disabling the component, you will wait for a while and the Launcher will automatically refresh the icon. See the picture below for the effect.
About the Columnist eclipse_xu: Senior Android development engineer; author of "Android Heroes", "Android Heroes: Magic Weapons", Android lecturer at MOOC; CSDN blog expert |
<<: Android Permission Management Principles (including 6.0)
>>: Experienced driver talks about racing technology: Android 7.0 adaptation experience
What exactly is advertising, trying to convince y...
In recent days, many places across the country ha...
Text/E-commerce consultant Lao Lu First summarize...
x Improve various leg shape training methods Basic...
Audit expert: Wang Linyu Deputy Chief Physician, ...
The concept of growth hacking has always been ver...
The era of TVs selling for money solely through h...
Screen: Sound Effects: operate: Plot: Experience:...
When eating apples, would you choose to eat the w...
German media reported that the US National Securit...
At a time when fruit prices are getting higher an...
Places for drinking tea in Yuelu District, Changs...
Qinghai-Tibet Plateau It is the best place to stu...
For many friends who have just started SEM, they ...
A while ago, an Airdesk video by the B station UP...