midletsuiteutils.java

来自「This is a resource based on j2me embedde」· Java 代码 · 共 832 行 · 第 1/3 页

JAVA
832
字号
/* * * * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */package com.sun.midp.main;import com.sun.j2me.security.AccessController;import com.sun.midp.lcdui.SystemAlert;import com.sun.midp.security.SecurityToken;import com.sun.midp.security.Permissions;import com.sun.midp.midletsuite.MIDletSuiteStorage;import com.sun.midp.midletsuite.MIDletSuiteLockedException;import com.sun.midp.midletsuite.MIDletSuiteCorruptedException;import com.sun.midp.midletsuite.MIDletInfo;import com.sun.midp.midlet.MIDletSuite;import javax.microedition.lcdui.AlertType;/** * The class designed to provide utils for starting MIDlet suites, * and scheduling their start using VM cycling mechanism. */public class MIDletSuiteUtils {    /** The unique ID of the last MIDlet suite to run. */    static int lastMidletSuiteToRun;    /** The class name of the last MIDlet to run. */    static String lastMidletToRun;    /**     * If not null, this will be available to the last MIDlet to run as     * application property arg-0.     */    static String arg0ForLastMidlet;    /**     * If not null, this will be available to the last MIDlet to run as     * application property arg-1.     */    static String arg1ForLastMidlet;    /** The unique ID of the next MIDlet suite to run. */    static int nextMidletSuiteToRun;    /** The class of the next MIDlet to run. */    static String nextMidletToRun;    /**     * If not null, this will be available to the MIDlet to run as     * application property arg-0.     */    static String arg0ForNextMidlet;    /**     * If not null, this will be available to the MIDlet to run as     * application property arg-1.     */    static String arg1ForNextMidlet;    /**     * If not null, this will be available to the MIDlet to run as     * application property arg-2.     */    static String arg2ForNextMidlet;    /**     * The minimum amount of memory guaranteed to be available     * to the VM at any time; &lt; 0 if not used.     */    static int memoryReserved;    /**     * The total amount of memory that the VM can reserve; &lt; 0 if not used.     */    static int memoryTotal;    /**     * Priority to set after restarting the VM; &lt;= 0 if not used.     */    static int priority;    /**     * Name of the profile to set after restarting the VM; null if not used.     */    static String profileName;    /**     * true if the new midlet must be started in debug     * mode, false otherwise.     */    static boolean isDebugMode;    /**     * Display an exception to the user.     *     * @param securityToken security token for displaying System Alert.     * @param exceptionMsg exception message     */    static void displayException(SecurityToken securityToken,				 String exceptionMsg) {        SystemAlert alert = new SystemAlert(securityToken, "Exception", 					    exceptionMsg, null, 					    AlertType.ERROR);        alert.run();        alert.waitForUser();    }    /**     * Starts a MIDlet in a new Isolate or     * queues the execution of the named Application suite to run.     * The current application suite should terminate itself normally     * to make resources available to the new application suite. Only     * one package and set of MIDlets can be queued in this manner.     * If multiple calls to execute are made, the package and MIDlets     * specified during the <em>last</em> invocation will be executed     * when the current application is terminated.     *     * @param id ID of an installed suite     * @param midlet class name of MIDlet to invoke     * @param displayName name to display to the user     *     * @return true if the MIDlet suite MUST first exit before the     * MIDlet is run     *     * @exception SecurityException if the caller does not have permission     *   to manage midlets     */    public static boolean execute(            int id, String midlet, String displayName) {        return executeWithArgs(            id, midlet, displayName, null, null, null, false);    }    /**     * Starts a MIDlet in a new Isolate or     * queues the execution of the named Application suite to run.     * The current application suite should terminate itself normally     * to make resources available to the new application suite. Only     * one package and set of MIDlets can be queued in this manner.     * If multiple calls to execute are made, the package and MIDlets     * specified during the <em>last</em> invocation will be executed     * when the current application is terminated.     *     * @param id ID of an installed suite     * @param midlet class name of MIDlet to invoke     * @param displayName name to display to the user     * @param isDebugMode true if the new midlet must be started in debug     *                    mode, false otherwise     *     * @return true if the MIDlet suite MUST first exit before the     * MIDlet is run     *     * @exception SecurityException if the caller does not have permission     *   to manage midlets     */    public static boolean execute(            int id, String midlet, String displayName, boolean isDebugMode) {        return executeWithArgs(            id, midlet, displayName, null, null, null, isDebugMode);    }    /**     * Starts a MIDlet in a new Isolate or     * queues the execution of the named Application suite to run.     * The current application suite should terminate itself normally     * to make resources available to the new application suite. Only     * one package and set of MIDlets can be queued in this manner.     * If multiple calls to execute are made, the package and MIDlets     * specified during the <em>last</em> invocation will be executed     * when the current application is terminated.     *     * @param securityToken security token of the calling class     *                      application manager     * @param suiteId ID of an installed suite     * @param midlet class name of MIDlet to invoke     * @param displayName name to display to the user     *     * @return true if the MIDlet suite MUST first exit before the     * MIDlet is run     *     * @exception SecurityException if the caller does not have permission     *   to manage midlets     */    public static boolean execute(            SecurityToken securityToken, int suiteId,            String midlet, String displayName) {        return executeWithArgs(            securityToken, suiteId, midlet,            displayName, null, null, null, false);    }    /**     * Starts a MIDlet in a new Isolate or     * queues the execution of the named Application suite to run.     * The current application suite should terminate itself normally     * to make resources available to the new application suite. Only     * one package and set of MIDlets can be queued in this manner.     * If multiple calls to execute are made, the package and MIDlets     * specified during the <em>last</em> invocation will be executed     * when the current application is terminated.     *     * @param securityToken security token of the calling class     *                      application manager     * @param suiteId ID of an installed suite     * @param midlet class name of MIDlet to invoke     * @param displayName name to display to the user     * @param isDebugMode true if the new midlet must be started in debug     *                    mode, false otherwise     *     * @return true if the MIDlet suite MUST first exit before the     * MIDlet is run     *     * @exception SecurityException if the caller does not have permission     *   to manage midlets     */    public static boolean execute(            SecurityToken securityToken, int suiteId,            String midlet, String displayName, boolean isDebugMode) {        return executeWithArgs(            securityToken, suiteId, midlet,            displayName, null, null, null, isDebugMode);    }    /**     * Starts a MIDlet in a new Isolate or     * queues the execution of the named Application suite to run.     * The current application suite should terminate itself normally     * to make resources available to the new application suite. Only     * one package and set of MIDlets can be queued in this manner.     * If multiple calls to execute are made, the package and MIDlets     * specified during the <em>last</em> invocation will be executed     * when the current application is terminated.     *     * @param suiteId ID of an installed suite     * @param midlet class name of MIDlet to invoke     * @param displayName name to display to the user     * @param arg0 if not null, this parameter will be available to the     *             MIDlet as application property arg-0     * @param arg1 if not null, this parameter will be available to the     *             MIDlet as application property arg-1     * @param arg2 if not null, this parameter will be available to the     *             MIDlet as application property arg-2     *     * @return true if the MIDlet suite MUST first exit before the     * MIDlet is run     *     * @exception SecurityException if the caller does not have permission     *   to manage midlets     */    public static boolean executeWithArgs(            int suiteId, String midlet, String displayName,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?