
Challenge submitted by NickDMax
CHALLENGE:
We'll keep up the mobile theme this month with JavaME. Write a basic App for a Cell Phone or Mobile device using JavaME
You don't need an JavaME device to try this challenge. The SDK comes with an emulator!
JavaME is one of the most widely used Mobile development platforms. Developing JavaME Applications is not very complicated and its one app that you can take with you and show all your friends (like pictures of the kids). Since JavaME development kits come with phone emulators you don't even have to own a mobile device to participate.
IDEAS:
- Note Taker
- Basic Game
- Private Photo Album
- Bluetooth File transfer
- Bluetooth P2P chat
- Bluetooth Head2Head game
- Text message client
- Twitter client
- DIC status updater?
- Mass Text app
HOW TO GET STARTED:
- : Download and install the Java 6 JDK (note: if you already develop in java you should already have this installed and just need to locate the JDK install directory).
- : Download and install the JavaME SDK 3.0 (note: if you do not wish to sign up for a Sun One account you can skip that part but the link is very very tiny
) - : (optional) download the SDK for your particular phone -- if you would like an emulator for your particular phone you can see if the manufacture has an JavaME SDK available -- I know Sony Ericsson does. Having the platform specific SDK may enable features specific to that manufacturer or phone. A list of links to various manufactures can be found here under Java ME Development Kits.
- : (optional) Get a better IDE: If you would prefer you can also download a more robust IDE such as NetBeans Mobility or Eclipse Pulsar.
The SDK comes with a basic IDE that you can use, it has a number of sample applications and emulators available. If you wish you can start right here in the SDK editor. Simply start the Java ME Platform SDK and choose an example project to open and explore.
If you would like to try using another IDE I can recommend Eclipse Pulsar (link above) which I have been using. I will update this post with a short description of how to get a basic HelloWorld application up and running. Meanwhile I highly suggest playing with the SDK demo applications.
EXAMPLE CODE:
package com.nickdmax.firstme;
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.*;
/**
* A basic Java ME MIDP MIDlet. Displays a form with the message "Hello Phone".
* MIDlets must implement three methods: startApp(), pauseApp(), destroyApp().<br>
* startApp() -- called to initialize or resume the application. <br>
* pauseApp() -- called to pause the application. <br>
* destroyApp() -- called when exiting - clean up application resources. <br>
* <br>To make the MIDlet have functionality it helps to respond to commands. To respond
* to commands you can implement the CommandListener interface.
* @author NickDMax @ DreamInCode
*/
public class HelloME extends MIDlet implements CommandListener {
private Command exitCmd; //The exit command...
private Display display; //The phone's display
private Form mainForm; //the main form for the application
/**
* Object Constructor -- initializes the Form and the Commands. You could place this
* stuff in the startApp() method but it only need to happen once to setup the form, so
* there really is no need to do it each time the startApp() method gets called.
*/
public HelloME() {
display = Display.getDisplay(this);
mainForm = new Form("Hello Phone!");
exitCmd = new Command("Exit", Command.EXIT, 1);
mainForm.addCommand(exitCmd);
mainForm.setCommandListener(this);
}
/**
* This is called when the App starts or is resumed after a pause (say a phone call),
* so we need to act according to state -- this simple app only has one state (display form).
*/
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(mainForm);
}
/**
* Called to cleanup the app. Not currently used.
*/
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
//No cleanup needed
}
/**
* Called when the phone needs to interrupt the app. You should save the state of the application
* and restore it in the startApp() method.
*/
protected void pauseApp() {
//Nothing to pause
}
/**
* Responding to commands. In this case there is only 1 command - exit.
*/
public void commandAction(Command c, Displayable d) {
if (c == exitCmd) {
try {
destroyApp(true);
} catch (Exception ignore) { }
notifyDestroyed();
}
}
}
WHERE TO GO FOR HELP:
If you're struggling, you can get help from Dream.In.Code's Mobile Development forum.
I find the Sony Ericsson Developer World to be an excellent resource (but I have a SE phone).

New Topic/Question
Reply



MultiQuote







|