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
Are aviation and aerospace the same thing? This i...
1. Two weeks ago, I encountered an interesting th...
[[147712]] Below are some Java thread-related int...
The arrival of mini programs has solved the diffi...
I had just come into contact with Zhihu at this t...
We all know that all revenue-generating categorie...
How much is the quote for customized Chuzhou tour...
IP derivatives have become a new target for enter...
[[126680]] Google Glass Although we read about sc...
" User growth is a term that everyone in the...
Last week, Google's Nest held a press conferen...
Hi-Fi is the abbreviation of High-Fidelity in Eng...
It is said that if the underwear is well chosen, ...
1. New car transaction situation In January, Beij...
According to recent news, the State Council issue...