After Android starts, In the Systemserver.java run method, the constructor of the Statusbarmanagerservice is called, and in the constructor method of Statusbarmanagerservice, all the icons of the system preset are loaded, the path is:/ Framework/base/core/res/res/values/config.xml in Micons.defineslots (Res.getstringarray ( com.android.internal.r.array.config_statusbaricons));.
As shown above, add an icon to the status bar, first to add your own field in the/framework/base/core/res/res/values/config.xml config_statusbaricons, the example chosen here, Is the face recognition icon I made at GM.
<string-array name= "Config_statusbaricons" > <item><xliff:g id= "id" >hotspot</xliff:g> </item> <item><xliff:g id= "id" >location</xliff:g></item> <item>< XLIFF:G id= "id" >bluetooth</xliff:g></item> ... <ITEM><XLIFF:G id= "id" >secure</xliff:g></item> <item><xliff:g id= "id" > clock</xliff:g></item> <item><xliff:g id= "id" >face_verify</xliff:g></item > </string-array>
This field is then defined in Phonestatusbarpolicy:
Private Static Final String slot_face_verify = "Face_verify";
Code path: Frameworks\base\packages\systemui\src\com\android\systemui\statusbar\phone\phonestatusbarpolicy.java
Then, in the constructor of the class, set the icon in, which can be invisible by default (depending on the interaction)
Nullfalse);
The control of the visibility of the icon is judged by the broadcast. Nature is for face recognition this situation, identify the service bind, send the start to recognize the broadcast, Onbind, send the end to identify the broadcast. The code to send the broadcast will not be written.
Else if (Action.equals (action_start_face_verity)) { true); Else if (Action.equals (action_stop_face_verity)) { false); }
Super simple! Of course, this is only for the system icon, for the signal icon, etc., in the Signalclusterview.
Save http://blog.csdn.net/yihongyuelan/article/details/7710584 this Good article. Although very old, but for the understanding of the status bar, very rewarding.
Add icon in status bar (Android 6.0)