Hullo members am developing a cell phone app for my mobile device and I have a java code I have written to do this. I would like any body to help me complete it so that its complete and make the time and date not to disappear after some time. I also want to include a button that pauses as well play the time from the current time. Thanks

Here is the code

import java.util.*;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class DateTime extends MIDlet implements CommandListener {
  private Form form;
  private Display display;
  private Command pause, resume, exit;
  private Timer tm;
  private Refresh refresh = new Refresh();
  private boolean on = true; // Is 'clock' is running or paused?

  public DateTime() {
    super();

    pause = new Command("Pause", Command.SCREEN, 2);
    resume = new Command("Resume", Command.SCREEN, 2);
    exit = new Command("Exit", Command.EXIT, 2);
  }

  public void startApp() {
    tm = new Timer();
    /* Your first part goes here ...
     * create the Form and Timer oblects
     * display the current time on the form, and
     * add the necessary commands or menu items.
     * leave the line above and below intact - they're for the timer
     */
     tm.schedule(refresh, 0, 1000);
  }

  public void pauseApp() {}

  public void destroyApp(boolean unconditional) {
    notifyDestroyed();
  }

  public void commandAction(Command c, Displayable s){
    /* Your third and last part is here ...
     * implement the command actions
     * make sure the commands Pause, Resume, & Exit do the right thing
     */
  }

  class Refresh extends TimerTask {
    public void run(){
      if (on) {
        /* Here you have the timer implementation for refreshing the screen
         * every second to dispay the current time, your second part.
         * reload the form with an update of the current time
         * note that this function is automatically called every second
         */
      }
    }
  }
}

I'm sorry to ask, but what is purpose of this application?

Am trying to learn mobile applications. so its for study purpose

Is there a way to help me out?

what are you having trouble with? I'd like to help, but what you're trying to do is foreign to me. I'd like to assume it is the same as any other Java code, but that may or may not be the case.

Am trying to learn mobile applications. so its for study purpose

Is there a way to help me out?

I'm not sure how I can help as you did not explain an issue you have, or more in detail what you trying to do. And so far from what I seen in your code I do not have reason to move away from DateField class as we know from JME and use it for general calculation purposes...

This code is not complete, when you run it, time displays but after a few seconds it disappears. so I dont want time to disappear.

Secondly I want to add a button in the code named play/pause which I want, if pressed plays time from current system time and if pressed again, pauses time without disappearing.

Another thing, when you run this code on a mobile device, after compilation using the J2ME toolkit, should be able to display the button written in java on the mobile device.

I have attached the toolkit, which I use to compile the java code.

Note: you should have java installed before you install the toolkit

>This code is not complete,
-I'm well aware of that

>when you run it, time displays but after a few seconds it disappears. so I dont want time to disappear.
- Caused by automated functionality to preserve resources which also include battery life, less light == longer battery life
At the moment every manufacturer uses different approach to regulate this, have look at this discussion . Hopefully this will cjange with new release of JME 3.0 SDK

>Secondly I want to add a button in the code named play/pause which I want, if pressed plays time from current system time and if pressed again, pauses time without disappearing.
-For the button either use traditional approach on any of Screen subclasses with use of Command class or you can set up custom object with use of Canvas (or GameCanvas if you require). Depending on selected approach way of running this "clock/time" will be most likely be dependent on updating value of string showed on screen either as StringItem or Graphics class method drawString()

>Another thing, when you run this code on a mobile device, after compilation using the J2ME toolkit, should be able to display the button written in java on the mobile device.
-As mentioned above...

>I have attached the toolkit, which I use to compile the java code.
-Sorry there is no attachment beside that coding attempt. Any manufacturer WTK ( Sony Ericsson, Nokia, Samsung, LG) are essentially standard WTK provided by Sun with emulators of their own devices which in 99% show completely different component layout from real device

>Note: you should have java installed before you install the toolkit
-Thank you, I'm well aware of this requirement

can you please help me integrate your solution to the code i provided to run at the beginning of this thread.

can you please help me integrate your solution to the code i provided to run at the beginning of this thread. then help me reproduce it on the next reply. thanks for your time

Not possible. I can help you fix errors if you get any, but you need to do your application on your own.

commented: Gotta love the "I want to learn" followed by the "please do it for me" schtick from some people +29
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.