:  » Google-tech » primosync » com » primosync » Java Open Source

Java Open Source » Google tech » primosync 
primosync » com » primosync »
   Copyright 2007 primosync

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   See the License for the specific language governing permissions and
   limitations under the License.
package com.primosync;

import java.util.TimeZone;

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

import com.primosync.component.*;
import com.primosync.log.*;

 * Public class responsible for starting the application through extension of MIDlet class.
 * Allows application management to control MIDlet, retrieve device properties, 
 * notify and request state changes. 
 * Methods allow the application management software to create, start, pause, and destroy MIDlet.  
public class PrimoSync extends MIDlet {

    private Display display;
    private static boolean started = false;
     * Signals MIDlet it has entered the Active state
     * @throws MIDletStateChangeException when a requested state change failed
     *        in response to state change calls into the application via the MIDlet interface 
    protected void startApp() throws MIDletStateChangeException {
        //check if the program has already started, this is needed when the program hides
        //and re appears - if the program is re apearing then do not show the login screen,
        //there is already an screen being shown
        if(started) return;
        started = true;
        //do the startup and show the login screen
        display = Display.getDisplay(this);
        if (checkRequirements()) {
    //Verifies if device has a Personal Information Manager (PIM) 
    //PIM is required to run the application - method should return immediately
    private boolean checkRequirements() {
        String pimVersion = System.getProperty("microedition.pim.version");
        if (pimVersion == null) {
            Form messageForm = new Form("Not supported");
            messageForm.append("Sorry, your phone is not supported");
            Command exitCommand = new Command("Exit", Command.EXIT, 2);
            messageForm.setCommandListener(new CommandListener() {
                 * Processes menu commands
                 * Notifies MIDlet it has entered Destroyed state
                 * @param command is command to execute
                 * @param displayable the form from which <code>command</code>
                 *                    originates
                public void commandAction(Command command, Displayable displayable) {
            return false;
        return true;

    private void setDependencies() {
//#ifdef DEBUG_LOG
//#         ErrorHandler.log = new StringBuffer();
        ErrorHandler.display = display;
        MVCComponent.display = display;
     * Signals MIDlet to enter paused state - okay to pause threads
    protected void pauseApp() {
     * Signals MIDlet to terminate and enter the Destroyed state for cleanup
    protected void destroyApp(boolean b) {

}  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.