|
MIDP Cell Phone Bugs
I wrote a small J2ME application for mobile phones ([jMensa]) and in this very small app I already encountered several bugs in J2ME implementations :-/ read below for some information about these bugs:
Siemens S55
There are three really annoying bugs that I encountered:
InputStream.read(byte[])
read(byte[]) does not return -1 when the end of stream has been reached. Also available() will always return the full length of the stream (at least for short streams, an URL in my case) and not the remaining bytes that can be read without blocking.
Missing UTF-8 support
It seems that the Siemens folks have been lazy and did not implement such a nice toll like UTF-8. Yes, there is a DataInputStream.readUTF(). But this will not help you if you want to read from a HTTP connection some plain text that is UTF-8 encoded (which is a nice thing since it is (should be!) portable and interoperable between virtually all systems). Therefore you need the ability to use the Reader class with UTF-8 encoding (like new Reader(inputStream, "UTF-8")) and the String constructor with UTF-8 encoding support. Hopefully Siemens will add this feature to the coming versions.
I have also tried to use this for translation files within the MIDlet JAR file but without success. If you want languages that won't fit into ISO-8859-1 you will encounter problems. This is why I wanted to use UTF-8 encoding...
Bug in Image class
For centered bold headings I derived the ImageItem class and used the Image object to draw the text to it. Here is the an excerpt of the code used:
public class HeadItem extends ImageItem {
/** Create a new one-line HeadItem.
* @param text Text to show
*/
public HeadItem(String text) {
super("", null, LAYOUT_CENTER + LAYOUT_NEWLINE_AFTER, "");
Font boldFont = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
Image headingImage = Image.createImage(boldFont.stringWidth(text), 3*boldFont.getHeight());
Graphics g = headingImage.getGraphics();
g.setFont(boldFont);
g.drawString(text, 0, boldFont.getHeight(), Graphics.TOP|Graphics.LEFT);
setImage(Image.createImage(headingImage));
}
}
This will lead to a graphic bug on the S55 (and only on the S55 as it seems). If you want to see how it should look and how it actually does look view the [bug screenshot].
Nokia 6310i
This phone has a nasty bug that I encountered when writing a workaround for the Siemens InputStream.read(byte[]) bug. Now I have two workarounds in the program...
InputStream.available()
This function always returns 0 on the 6310i. It does not tell you the length (for short strings, URL in this case) nor does it give you the remaining bytes readable without blocking. It seems that every read call will be blocking on the 6310i. This would not be a big deal if there was not the read(byte[]) bug...
|
|