Main.java

/*
 * Copyright © 2011 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners. 
 * See LICENSE.TXT for license information.
 */ 

package com.nokia.example.sudokumaster;

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

public class Main extends MIDlet {

    private boolean closed = false;

    private SudokuCanvas sudokuCanvas;

    public void startApp() {
        if(sudokuCanvas == null) {
            sudokuCanvas = new SudokuCanvas(this);
            Display.getDisplay(this).setCurrent(sudokuCanvas);
        }
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        closed = true;
        if(sudokuCanvas != null) sudokuCanvas.saveGameState();
    }

    public void close() {
        destroyApp(true);
        notifyDestroyed();
    }

    public boolean isClosed() {
        return closed;
    }
}