package zieckey.j2me.study.mmapi;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/**
* 本程序用来说明获得当前硬件设备的媒体处理能力集的方法
* @author zieckey
*/
public class ConfigMIDlet extends MIDlet implements CommandListener
{
private Display display;
private Command cmdExit;
private List menu;
public ConfigMIDlet( )
{
display = Display.getDisplay( this );// 提取系统设备的Display对象
cmdExit = new Command( "Exit", Command.SCREEN, 2 );// 对该菜单的相应应用到当前整个屏幕
}
protected void startApp() throws MIDletStateChangeException
{
// 构造一List组件,用于显示文本
menu = new List( "Main", List.IMPLICIT );
if ( AppRuntimeDetect.CAPTURE_AUDIO )
{
menu.append( "Capture audio", null );
}
if ( AppRuntimeDetect.CAPTURE_VIDEO )
{
menu.append( "Capture video", null );
}
if ( AppRuntimeDetect.IS_MIDP2 )
{
menu.append( "Is MIDP 2.0", null );
}
if ( AppRuntimeDetect.CAPTURE_PHOTO )
{
menu.append( "Capture photo", null );
}
menu.addCommand( cmdExit );
menu.setCommandListener( (CommandListener)this );
// 将menu设置为当前显示的组件
display.setCurrent( menu );
}
protected void destroyApp( boolean arg0 ) throws MIDletStateChangeException
{
}
protected void pauseApp()
{
}
public void commandAction( Command cmd, Displayable arg1 )
{
// 对该命令的响应
if ( cmd == cmdExit )
{
try
{
destroyApp( true );
} catch ( MIDletStateChangeException e )
{
e.printStackTrace( );
}
notifyDestroyed( );
}
}
}
|