Thursday 27 November 2008

Installing Java Application in the Motorola Phone

This seems more difficult then I thought.
I bought the Motorola V3xx phone and it has got a USB Cable.
BUT!, no cd for me to install the software!

This software is important so that the pc would know what to do when you connect the Motorola phone to the pc. Without the software, the pc would mention that the phone is not installed properly or something like that.

These are the steps that I took:
(For any problems faced, read below)

Step 1.
Sign up at the Motorola Developer's Website.

Step 2.
Then, I had to download the following:

Handset USB Driver for Windows: used for connecting your Motorola handset to a Windows computer via a USB cable
Motorola Midway Tool: used for downloading Java™ ME applications to your phone using a serial or USB cable

**Please take note you'll need to install the Handset USB Driver for Windows before installing the Midway Tool**

Step 3.
After that, follow the instructions on using the Midway Tool and you are done.

**Please take note:
- insert the USB cable at the correct times.
- ensure that the JAD and JAR files under the same folder.

Problems:

1. Enabling the Java App Loader in Motorola
In the Midway tool, there is a step whereby you need to open the Java App Loader in the Java Settings. However, it is not possible in all phones. You may need to send it to Motorola for them to enable it for you! This is a complete waste of time!

Solution:
I downloaded MotoMidMan together with RSD Lite and used it to enable the java app loader and it works!

It is hard to really say which one solution works so it is best for you to google and try it out. I did heard of The UID Extraction Tool on the MOTODEV web site (MOTODEV) which can be used to enable JAL if it is not visible in the handset's "Java Settings" menu. I have not tried it but you might want to try!

However, I recommend you NOT to use p2ktools or p2kman. It just doesn't work for me.

All the best!

Monday 24 November 2008

Can't input anything into EditField!

I created a J2ME Application for Blackberry phone and initially, I have this piece of code which is to detect when user presses the ESC button.

//When application closes
public boolean onClose() {
System.exit(0);
return true;
}

//When user press ESC key OnClose() would be called
public boolean keyChar(char key, int status, int time) {
if(key == Characters.ESCAPE){
onClose();
}
return true;
}


However, when doing this, I faced a problem of allowing the user to input anything into the EditField!!
So I just had to add this piece of line in the keyChar method to make it work :)

return super.keyChar(key, status, time);

You keyChar method should now look like this:

//When user press ESC key OnClose() would be called
public boolean keyChar(char key, int status, int time) {
if(key == Characters.ESCAPE){
onClose();
}
return super.keyChar(key, status, time);
}


Problem solved! :D

Sony Ericsson does not allow + sign in textbox!

I am currently developing a J2ME application for Sony Ericsson phone.
In the application, I have a texbox which only allow users to input numbers and certain signs as how you would enter your normal phone numbers.

This is the code that I use:

TextBox my_box = new TextBox("Enter here", "", 50, TextField.PHONENUMBER);

However, I faced a problem in Sony Ericsson as I could not enter a plus sign(+).
I checked tried in Nokia S40 and it works!
If you realised in Sony Ericsson, the key pad to input the + sign is the same as with the number 0.
So when you tried to input the + sign, it is always the number 0 that appears. :(

I then realised that there's no bug actually!
To insert a + sign in Sony Ericsson, one should press on the 0 longer. :)

Friday 21 November 2008

Clear background Colour

I am finding difficulty doing research on finding a clear background colour for my j2me application that is using low level apis.

Currently, I am using these colours:

0xFFFFFF = white
0xBCEE68 = green
0x000000 = black

To set the background colour, use this method
g.setColor(0xFFFFFF);

To set the font colour, use this method
g.setFont((0xFFFFFF);

g in this case refers to Graphics and the bolded part is to specify the colour.
For more information about colours, go to this link: http://www.devx.com/wireless/Article/21452

In the example from this site: http://developers.sun.com/mobility/midp/articles/customitems/index.html

// clear all with background color
g.setColor( DISPLAY.getColor( DISPLAY.COLOR_BACKGROUND ) );
g.fillRect( 0, 0, w, h );

// now use foreground color for drawing
g.setColor( DISPLAY.getColor( DISPLAY.COLOR_FOREGROUND ) );


"We discover the device's default background and foreground colors by calling the Display's getColor() method twice, passing it the appropriate constant each time, COLOR_BACKGROUND, then COLOR_FOREGROUND. Whether we elect to use the default colors or specify our own, OutlineItem.paint() fills a rectangle with the background color, then switches to the foreground color to draw the rest of the content."