Add icon in status bar (Android 6.0)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.