简体   繁体   中英

Android show icon in Status bar

I want to show my App Icon in status bar without notification tray/drawer. just like alarm icon shows. I am also making application similar to alarm clock.

I have dig out few questions on stackoverflow, some say it is not possible without notification tray/drawer, but I have seen few apps doing this.

Can any one guide me better?

Thanks

You gave some alarm clock applications as examples, so I think you can start from understanding what this alarm clock icon in status bar is, and how it is shown there.

I note, that, as you can see, application "Alarm Clock Plus" doesn't set its own icon to status bar, just system icon for alarm.

You can see here how you can manipulate this icon on Pre-Lollipop only:

protected void setStatusBarIcon(boolean enabled)
{
    Intent alarmChanged = new Intent("android.intent.action.ALARM_CHANGED");
    alarmChanged.putExtra("alarmSet", enabled);
    sendBroadcast(alarmChanged);
}

If you can give an example of application that puts its own (different from system alarm icon) icon to status bar (not as notification), it could help to see that it is possible. Unfortunately, I don't think that it is possible.

Even just logically: there are two parts of status bar – user (notifications) and system (other). If system allows to put something to system part – there will be so much useless icons (posted by other applications), and there will be no consistency, and it might break all of the use experience. I think.

Hope it 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