2

I want to show a number in the status bar, like all the battery apps do (when they show the percentage of the battery in the status bar, usually with a persistent notification).

It seems that I can't set a text to appear on the status bar, only an image.

So is the only way is to create X images (e.g. 100 images for battery apps each with a different name) and to switch between them?

Thanks.

Ran
  • 4,117
  • 4
  • 44
  • 70
  • 1
    Share the code how you are doing it . Then we may be able to help ?? – preeya Dec 28 '12 at 14:02
  • there is no code, I'm looking for one. The standard notification code can be seen here: http://developer.android.com/guide/topics/ui/notifiers/notifications.html . I just want to display text instead of an icon on the status bar. – Ran Dec 28 '12 at 14:07

1 Answers1

2

Use setNumber() with your Notification.Builder or NotificationCompat.Builder.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • but that number appears on the notification. I want to show a number on the status bar, like in https://play.google.com/store/apps/details?id=com.moddedlogic.android.BatteryStatus – Ran Dec 30 '12 at 09:47
  • 1
    @Ran: Well, that "number" *is* a `Notification`. You either go with 100 images or you use `setNumber()`. – CommonsWare Dec 30 '12 at 12:19
  • I actually wanted to display a decimal number, so I would need infinite images. :) Thanks. – Ran Dec 30 '12 at 12:53
  • @Ran: Unfortunately, in most cases, these images have to be resources. I think the "large" image can be a `Bitmap`, which you could build on the fly, but that will only be used in some circumstances (e.g., Android 3.x tablets). – CommonsWare Dec 30 '12 at 12:55