Namespaces
Variants
Actions
Revision as of 12:49, 18 June 2012 by hamishwillee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Display.getColor() returns incorrect values in Series 40 (Known Issue)

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.
Article Metadata

Tested with
Devices(s): All

Compatibility
Platform(s): Series 40 2nd Edition,

Article
Keywords: Display.getColor(int colorSpecifier)
Created: User:Technical writer 1 (10 Feb 2009)
Last edited: hamishwillee (18 Jun 2012)


Contents

Overview

Display.getColor() returns incorrect values in Series 40 devices.

Description

According to the MIDP specifications, getColor(int colorSpecifier) should return an integer value of one of the colours from the high-level user interface colour scheme, in the form 0x00RRGGBB based on the colorSpecifier passed in.

However, in Series 40 devices, the method returns the colour value in the incorrect form 0xFFRRGGBB.

How to reproduce

The described problem can be reproduced by using the following code:

 import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
 
public class GetColor_Test extends MIDlet implements CommandListener {
 
private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
private Display display;
 
public GetColor_Test() {
display = Display.getDisplay(this);
}
 
protected void startApp() {
int backgroundColour = display.getColor(Display.COLOR_BACKGROUND);
int foregroundColour = display.getColor(Display.COLOR_FOREGROUND);
int highlightBackgroundColour = display.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND);
int highlightForegroundColour = display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND);
int borderColour = display.getColor(Display.COLOR_BORDER);
int highlightBorderColour = display.getColor(Display.COLOR_HIGHLIGHTED_BORDER);
 
Form mainForm = new Form("GetColor Test");
mainForm.addCommand(CMD_EXIT);
mainForm.setCommandListener(this);
 
mainForm.append("The reported colours should have the format " +
"0x00RRGGBB, where RR, GG and BB are the hex values " +
"for the red, green and blue components of the colour.\n");
 
mainForm.append("Background colour: " + convertToHexString(backgroundColour));
mainForm.append("Foreground colour: " + convertToHexString(foregroundColour));
mainForm.append("Highlight background colour: " + convertToHexString(highlightBackgroundColour));
mainForm.append("Highlight foreground colour: " + convertToHexString(highlightForegroundColour));
mainForm.append("Border colour: " + convertToHexString(borderColour));
mainForm.append("Highlight border colour: " + convertToHexString(highlightBorderColour));
 
display.setCurrent(mainForm);
}
 
protected void pauseApp() {
}
 
protected void destroyApp(boolean arg0) {
}
 
private String convertToHexString(int i) {
String string = Integer.toHexString(i);
string = string.toUpperCase();
while (string.length() < 8) {
string = "0" + string;
}
return "0x" + string + "\n";
}
public void commandAction(Command c, Displayable d) {
if (c == CMD_EXIT) {
destroyApp(false);
notifyDestroyed();
}
}
}

Solution

No solution.

194 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved