简体   繁体   中英

android app icon in status bar

I am able to make an entry in the notification bar for my app, but I want to make an icon for my app in the status bar, where battery, wi-fi, bluetooth,time icons are shown. I have searched about this, but got this much- it can't be controlled from the app only, while building android ,some-where in the frameworks directory of android source-code we have to put some lines to get it done, I don't have any clue how is it managed.

Sorry I don't have enough reputation to add this as a comment, but have you looked at similar questions like these?. You can add a drawable resource for the icon you want and set flags on your notification so that should allow the icon to remain in the status bar. FLAG_NO_CLEAR and FLAG_ONGOING_EVENT can allow you to make an icon appear in the status bar as the answerd to these questions describes.

How to show an icon in the status bar when application is running, including in the background?

controlling the android status bar icon

If you have a full checkout of AOSP I would recommend checking out the StatusBarManager service then. The notification uses callbacks inside of this service when showing notificatons. There is also a binder interface that allows setting icons.

in /frameworks/base/services/java/com/android/server/StatusBarManagerService.java and /frameworks/base/core/java/com/android/internal/statusbar/IStatusBarService.aidl void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription);

void setIconVisibility(String slot, boolean visible);

in /frameworks/base/core/res/res/values/config.xml

   <item><xliff:g id="id">ime</xliff:g></item>
    <item><xliff:g id="id">sync_failing</xliff:g></item>
    <item><xliff:g id="id">sync_active</xliff:g></item>
    <item><xliff:g id="id">gps</xliff:g></item>
    <item><xliff:g id="id">bluetooth</xliff:g></item>
    <item><xliff:g id="id">nfc</xliff:g></item>
    <item><xliff:g id="id">tty</xliff:g></item>
    <item><xliff:g id="id">speakerphone</xliff:g></item>
    <item><xliff:g id="id">mute</xliff:g></item>
    <item><xliff:g id="id">volume</xliff:g></item>
    <item><xliff:g id="id">wifi</xliff:g></item>
    <item><xliff:g id="id">cdma_eri</xliff:g></item>
    <item><xliff:g id="id">data_connection</xliff:g></item>
    <item><xliff:g id="id">phone_evdo_signal</xliff:g></item>
    <item><xliff:g id="id">phone_signal</xliff:g></item>
    <item><xliff:g id="id">battery</xliff:g></item>
    <item><xliff:g id="id">alarm_clock</xliff:g></item>
    <item><xliff:g id="id">secure</xliff:g></item>
    <item><xliff:g id="id">clock</xliff:g></item>

the are the values for slots that get added by default to the statusbar

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM