Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My first mobile application

 
Ali Kiyani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Today is my first day in MIDP.

I am trying to make a calculator that will add two numbers and then will display the result.

I have added a Form and on that form there are two TextFields. There are also two buttons OK and CANCEL.

What I want is when the user presses the OK button then it should call the function AddNumber() but I don't know how to do that because when I presses it, it goes back to the previous screen like CANCEL button. How can I do that?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, when you created your Button you made it of type OK, which defaults to closing the Form. What you want is the type that is SCREEN.

Taken from the Javadocs


static int OK
A command that is a standard positive answer to a dialog implemented by current screen.
static int SCREEN
Specifies an application-defined command that pertains to the current screen.


Mark
 
Ali Kiyani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it works!

One more thing. When I ran the program it created a .jad file and one MANIFEST file. I transferred them in my friend's Samsung mobile (it supports java but don't know which version) but it didn't work there! Is there anything else that I need to do to install the program on mobile!?
How do I know on which mobile my program will work!?

Take a look at source code which may give you some idea.


[ September 16, 2005: Message edited by: Ali Kiyani ]
 
Ali Kiyani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I managed to run it on mobile. The solution is, create a JAR file of your project and install it rather than installing JAD file on mobile.

But my other questions still remains the same and that is:

How do I know that my application will work on certain models? As you can see I have not defined anything in the code so I guess it picks up the default settings. What are those default settings and how can I define my own that this application will target some specific models?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that's the trick. J2ME CLDC, MIDP are just specification for the device manufacturer to implement if it wants to call the phone a J2ME enabled phone for whatever version if MIDP CLDC. Some devices has proprietary APIs that you can add on top of J2ME, but then your code is locked to that device.

If you want to create specific jars for specific devices based on features that one phone implements that another does not. You either have to have spereate projects for each type of device and have special code in each for that particular device.

Or you can make it "easier" on yourself by using J2ME Polish. Now "easier" in that you will have only one baseline of code, but you would still have to learn J2ME Polish to use it to its fullest potential.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic