Joke Collection Website - Public benefit messages - Ask Android to realize the problem of adding numbers to the upper right corner of SMS icons. Kneel down and ask God.

Ask Android to realize the problem of adding numbers to the upper right corner of SMS icons. Kneel down and ask God.

Please refer to the following:

Implementation principle:

First of all, we should understand that it is not the application itself that handles the modification of the startup icon and the dynamic modification of the icon, but mainly in the launcher. When the application is installed, updated and uninstalled, there will be a broadcast. Launcher registers the broadcast in LauncherApplication, processes the received broadcast message in LauncherModel and reloads the updated application information (such as application icon, text, etc.). However, the native android system does not support this function (and the effect of dynamically modifying the startup icon cannot be achieved by sending a specific system broadcast). However, under the deep customization of the system source code of powerful third-party Android mobile phone manufacturers (such as Samsung and Xiaomi), by modifying the Launcher source code, a new broadcast receiver is added/registered to receive the unread message number broadcast sent by the application. After receiving the broadcast, the system will hand over the event showing the number of unread messages to Launcher for processing, and call related methods to redraw the icon of the application, so as to achieve the effect of dynamically updating the icon of the application.

Sample code: