BlackBerry - How to show the system status bar on top of the application screen

My question is quite simple, but I could not find the answer, maybe because I use the wrong terms, but let me try: is there a way for the BlackBerry application (extension of the usual screen component) to keep the status bar visible (by the status bar, so that to clarify, I mean the area where you see the battery power, network name, signal strength, etc.)?

Thank you

+4
source share
4 answers

So far (in my experience, before the operating system version 4.6), the API has not been subjected to this, oddly enough. Of course, you can program your own status bar, as many applications do, if you think it is necessary. But you need to collect information and display the status information with a logical encoding in your own program.

+3
source

Here is a sample code. First, for a good title bar, look here: http://www.naviina.eu/wp/blackberry/iphone-style-field-for-blackberry/

To display an image of battery strength:

import net.rim.device.api.system.Bitmap; import net.rim.device.api.system.DeviceInfo; ... public static Bitmap getBatteryImage(){ int batteryPercent = DeviceInfo.getBatteryLevel(); int val = 1; if(batteryPercent > 80){ val = 5; }else if(batteryPercent > 60 ){ val = 4; }else if(batteryPercent > 40){ val = 3; }else if(batteryPercent > 20){ val = 2; }else { val = 1; } Bitmap batteryImage = Bitmap.getBitmapResource("mybattery"+val+".png"); return batteryImage; } ... 

You need to create mybattery1.png images on mybattery5.png and put them in the src folder. A good size to start with is 28x11 pixels (GIMP is a good free image editor). If you used the barcode on Naviina.eu, paste the following code into the drawing method, for example:

 protected void paint(Graphics graphics) { ... int w = this.getPreferredWidth(); int h = this.getPreferredHeight(); Bitmap batteryImage = getBatteryImage(); int batteryStartY = (h - batteryImage.getHeight()) / 2; graphics.drawBitmap(w - batteryImage.getWidth(), batteryStartY, w, h, batteryImage, 0, 0); ... } 

Some notes: the image does not refresh unless you cancel the screen or click / click on another screen. Alternatively, you might want to get smaller images for Pearl vs Curve or Storm.

+2
source
+1
source

There are actually three places where you can paste status information into a MainScreen subclass:

  • Banner Area - Located at the Top of the Screen
  • Title bar - located below the banner bar and usually has a different background
  • Status area - bottom of the screen

You use setBanner (field), setTitle (field) and setStatus (field) to display information as shown below:

  HorizontalFieldManager hfm = new HorizontalFieldManager(); EncodedImage logo = EncodedImage.getEncodedImageResource("img/Logo.png"); Bitmap bm = logo.getBitmap(); hfm.add(new BitmapField(bm)); hfm.add(new LabelField("Banner area")); setBanner(hfm); setTitle(new LabelField("Title area", LabelField.FIELD_HCENTER)); setStatus(new LabelField("Status area", LabelField.FIELD_HCENTER)); 

The advantage is that each method takes a field as an argument, and the programmer can create a complex field with managers.

0
source

All Articles