⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 detectmidlet.java

📁 <j2me 开发精解> 詹建光著 里所有的源码。对J2me的开发相当有帮助
💻 JAVA
字号:
package com.j2medev.ch2.property;

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

public class DetectMIDlet extends MIDlet {
    
    private static DetectMIDlet instance = null;
    private Display display = null;
    private Displayable form = null;
    
    public DetectMIDlet() {
        instance = this;
    }
    
    protected void startApp() {
        if(display==null) {
            // 首次启动应用程序
            display = Display.getDisplay(this);
            form = new TestForm();
            display.setCurrent(form);
        } else{
            display.setCurrent(form);
        }
    }
    
    protected void pauseApp() {}
    
    protected void destroyApp(boolean unconditional) {}
    
    public static void quitApp() {
        instance.destroyApp(true);
        instance.notifyDestroyed();
        instance = null;
    }
}

class TestForm extends Form implements CommandListener {
    
    private Command exit = new Command("退出", Command.EXIT, 0);
    
    public TestForm() {
        super("J2ME平台测试");
        String s;
        //CLDC版本属性
        s = System.getProperty("microedition.configuration");
        append(getValue("CLDC版本", s));
        //MIPD版本属性
        s = System.getProperty("microedition.profiles");
        append(getValue("MIDP版本",s));
        
        s = System.getProperty("microedition.platform");
        append(getValue("软件平台", s));
        
        s = System.getProperty("microedition.encoding");
        append(getValue("系统编码", s));
        
        s = System.getProperty("microedition.locale");
        append(getValue("区域设置", s));
        
        s = System.getProperty("microedition.jtwi.version");
        append(getValue("JTWI", s));
        
        //判断是否支持MMAPI
        s = System.getProperty("microedition.media.version");
        append(getValue("MMAPI", s));
        //判断是否支持WMA
        s = System.getProperty("wireless.messaging.sms.smsc");
        if(s!=null) {
            append(getValue("WMA", "支持"));
            append(getValue("SMS", s));
            s = System.getProperty("wireless.messaging.mms.mmsc");
            append(getValue("MMS", s));
        } else
            append(getValue("WMA", null));
        //判断是否支持蓝牙
        s = System.getProperty("bluetooth.api.version");
        append(getValue("蓝牙", s));
        //判断是否支持个人信息管理
        s = System.getProperty("microedition.pim.version");
        append(getValue("PIM", s));
        //判断是否支持文件系统
        s = System.getProperty("microedition.io.file.FileConnection.version");
        append(getValue("FileConnection", s));
        //判断是否支持SIP
        s = System.getProperty("microedition.sip.version");
        append(getValue("SIP", s));
        //判断是否支持M3G JSR 184
        s = System.getProperty("microedition.m3g.version");
        append(getValue("M3G", s));
        addCommand(exit);
        setCommandListener(this);
    }
    
    private String getValue(String prompt, String s) {
        return prompt + ":" + (s==null ? "不支持" : s) + "\n";
    }
    
    public void commandAction(Command c, Displayable d) {
        if(c==exit){
            DetectMIDlet.quitApp();
        }
    }
    
}

⌨️ 快捷键说明

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