📄 使用j2me程序测试midlet的生命周期-开发者网络-java-天极yesky.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0038)http://dev.yesky.com/143/3332643.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>使用J2ME程序测试MIDlet的生命周期-开发者网络-JAVA-天极Yesky</TITLE>
<META content=使用J2ME程序测试MIDlet的生命周期, name=description>
<META content=使用J2ME程序测试MIDlet的生命周期, name=keywords>
<META content="天极Yesky | 全球中文IT第一门户" name=author>
<META content="天极Yesky | 全球中文IT第一门户" name=Copyright>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv=Content-Language content=zh-CN><LINK media=all
href="使用J2ME程序测试MIDlet的生命周期-开发者网络-JAVA-天极Yesky.files/y_mobile_content.css"
type=text/css rel=stylesheet>
<SCRIPT
src="使用J2ME程序测试MIDlet的生命周期-开发者网络-JAVA-天极Yesky.files/showlay.js"></SCRIPT>
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY><!--页面头部--><!--头部-->
<DIV id=topmenu><A href="http://www.yesky.com/">Yesky首页</A>| <A
href="http://product.yesky.com/">产品报价</A>| <A
href="http://cseek.yesky.com/">行情</A>| <A href="http://mobile.yesky.com/">手机</A>
| <A href="http://digital.yesky.com/">数码</A> | <A
href="http://notebook.yesky.com/">笔记本</A> | <A
href="http://pc.yesky.com/">台式机</A> | <A href="http://diy.yesky.com/">DIY硬件</A>
| <A href="http://oa.yesky.com/">外设</A> | <A href="http://net.yesky.com/">网络</A>
| <A href="http://dh.yesky.com/">数字家庭</A> | <A
href="http://lab.yesky.com/">评测</A> | <A href="http://soft.yesky.com/">软件</A> |
<A href="http://e.yesky.com/">e时代</A> | <A href="http://game.yesky.com/">游戏</A>
| <A href="http://pic.yesky.com/">图片</A> | <A
href="http://desktop.yesky.com/">壁纸</A> | <A href="http://q.yesky.com/">群乐</A> |
<A href="http://my.yesky.com/">社区</A> | <A href="http://blog.yesky.com/">博客</A>
| <A href="http://www.mydown.com/">下载</A></DIV>
<DIV id=topbox>
<DIV class=tleft><A href="http://www.yesky.com/"><IMG alt=天极Yesky_全球中文IT第一门户
src="使用J2ME程序测试MIDlet的生命周期-开发者网络-JAVA-天极Yesky.files/logo.gif"
border=0></A></DIV>
<DIV class=tad><SPAN id=ad1></SPAN></DIV>
<DIV id=search>
<DIV>
<FORM name=searchform action=http://search.chinabyte.com/search method=get
target=_blank><INPUT id=searchzz onmouseover=this.focus() onfocus=this.select()
name=q><INPUT type=hidden value=GB2312 name=encoding><INPUT type=hidden
value=connect name=dir><INPUT type=hidden value=20002 name=cid><INPUT id=search_btn type=submit value=天极搜索> </FORM></DIV>
<DIV class=tdq>
<DIV class=rightarea><A href="http://bj.yesky.com/">北京</A> <A
href="http://hd.yesky.com/">上海</A> <A href="http://gd.yesky.com/">广东</A> <A
href="http://xa.yesky.com/">西安</A><BR><A href="http://cq.yesky.com/">重庆</A> <A
href="http://cd.yesky.com/">成都</A> <A href="http://sy.yesky.com/">沈阳</A> <A
href="http://js.yesky.com/">江苏</A> </DIV>
<DIV class=rightarea_right><A
href="http://my.yesky.com/">用户<BR>登录</A></DIV></DIV></DIV>
<DIV class=tright>
<DIV class=box1>
<SCRIPT src="使用J2ME程序测试MIDlet的生命周期-开发者网络-JAVA-天极Yesky.files/content_text_ad.js"
type=text/javascript></SCRIPT>
</DIV></DIV></DIV>
<SCRIPT src="使用J2ME程序测试MIDlet的生命周期-开发者网络-JAVA-天极Yesky.files/flash.js"
type=text/javascript></SCRIPT>
<DIV id=childmenu><A href="http://soft.yesky.com/">软件频道></A><A
href="http://dev.yesky.com/">程序开发></A><A
href="http://dev.yesky.com/devjava/">Java</A><A
href="http://dev.yesky.com/ysdevvb">VB</A><A
href="http://dev.yesky.com/ysdevvc">VC</A><A
href="http://dev.yesky.com/ysdevdelphi">Delphi</A><A
href="http://dev.yesky.com/ysdevc">C/C++</A><A
href="http://dev.yesky.com/web/">Web开发</A><A
href="http://dev.yesky.com/msdn/">微软专栏</A><A
href="http://dev.yesky.com/devydkf/">移动</A><A
href="http://dev.yesky.com/devsjk/">数据库</A><A
href="http://dev.yesky.com/ysdevcxrs">程序人生</A><A
href="http://dev.yesky.com/ysdevrjgc">软件工程</A>|<A
href="http://soft.yesky.com/lesson/">产品中心</A><A
href="http://www.mydown.com/soft/develop/news.shtml">下载</A><A
href="http://q.yesky.com/group/179"><FONT
color=#ff0000>群乐:大家耍QQ</FONT></A></DIV><!--导航条-->
<DIV id=location>
<DIV class=loleft>您现在的位置: <A href="http://www.yesky.com/">天极Yesky</A> > <A
href="http://soft.yesky.com/">软件频道</A> > <A
href="http://dev.yesky.com/">开发者网络</A> > 使用J2ME程序测试MIDlet的生命周期</DIV>
<DIV class=adright><SPAN id=ad2></SPAN></DIV></DIV><!--内容块开始-->
<DIV id=conbox><!--左边开始-->
<DIV id=conleft>
<DIV id=contopla1>
<DIV id=__001>
<DIV class=qkong></DIV>
<DIV class=qw1>全文</DIV>
<DIV class=zkong>
<DIV class=kl></DIV>
<DIV class=bj><A href="http://dev.yesky.com/143/3332643.shtml#pls"
target=_self>评论</A></DIV>
<DIV class=kr></DIV>
<SCRIPT type=text/javascript>
var titiepic ="#";
if (titiepic!="#")
{
document.write("<div class=\"kl\"></div><div class=\"bj\"><a href=\"#\" target=\"_blank\">图片</a></div><div class=\"kr\"></div>");
}
</SCRIPT>
<DIV class=ql>
<DIV class=kl></DIV>
<DIV class=bj>群乐:<A id=mainGroupURL
href="http://q.yesky.com/group/209519">Java</A></DIV>
<DIV class=kr></DIV></DIV></DIV></DIV></DIV>
<DIV class=topadbg><SPAN id=ad10></SPAN></DIV><A name=top></A>
<DIV id=contitle>
<H1>使用J2ME程序测试MIDlet的生命周期</H1></DIV>
<DIV id=conauthor><SPAN>2007-05-15 07:00 </SPAN><SPAN>作者: </SPAN><SPAN>出处:
天极Yesky软件频道 </SPAN><SPAN>责任编辑:<A title=向本编辑提问
href="http://comments.yesky.com/t/¬ÁÖ¼Î/6,324/3332643.shtml"
target=_blank>卢林嘉</A> </SPAN></DIV>
<DIV class=topadbg><SPAN id=ad9></SPAN></DIV>
<DIV id=conneirong><SPAN id=ad3></SPAN>
<DIV class=guanggao><SPAN id=contentAdv></SPAN></DIV>
<P> 在MIDlet程序学习中,生命周期是一个比较抽象的概念。其实生命周期就是一个简单的规定,规定了MIDlet中的每个方法,什么时候被系统调用。下面是一个示例代码,在每个方法的内部都输出一条语句,可以根据程序的输出结果来验证各方法被调用的顺序,具体代码如下:</P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><SPAN
lang=EN-US><FONT face="Times New Roman" size=3></FONT></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd">
<TABLE
style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted"
cellSpacing=0 cellPadding=6 width="95%" align=center border=0>
<TBODY>
<TR>
<TD style="WORD-WRAP: break-word" bgColor=#f3f3f3><FONT
style="FONT-WEIGHT: bold; COLOR: #990000">以下是引用片段:</FONT><BR>//文件名:LifeCircleMIDlet.<A
class=bluekey href="http://dev.yesky.com/devjava/" target=_blank>Java</A>
<BR>import javax.microedition.midlet.*; <BR>/**
<BR> * 测试MIDlet的生命周期 <BR> */
<BR>public class LifeCircleMIDlet extends MIDlet{
<BR> /**
<BR> * 默认构造方法
<BR> */
<BR> public LifeCircleMIDlet(){
<BR> System.out.println("默认构造方法");
<BR> }
<BR>
<BR> /**
<BR> * 启动方法
<BR> */
<BR> public void startApp(){
<BR> System.out.println("startApp方法");
<BR> }
<BR>
<BR> /**
<BR> * 暂停方法
<BR> */
<BR> public void pauseApp(){
<BR> System.out.println("pauseApp方法");
<BR> }
<BR>
<BR> /**
<BR> * 销毁方法
<BR> * @param b
<BR> */
<BR> public void destroyApp(boolean b){
<BR> System.out.println("destroyApp方法");
<BR> }
<BR>
<BR>}</TD></TR></TBODY></TABLE></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"> </P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"> 在J2WTK中运行该程序时,可以使用浏览器中的“MIDlet”菜单中的暂停和恢复菜单,模拟暂停事件。</P><BR> 阅读关于
<A href="http://search.yesky.com/search?q=JAVA" target=_blank><FONT
color=red>JAVA</FONT></A> <A href="http://search.yesky.com/search?q=J2ME"
target=_blank><FONT color=red>J2ME</FONT></A> <A
href="http://search.yesky.com/search?q=%B5%F7%D3%C3" target=_blank><FONT
color=red>调用</FONT></A> <A href="http://search.yesky.com/search?q=%D3%EF%BE%E4"
target=_blank><FONT color=red>语句</FONT></A> <A
href="http://search.yesky.com/search?q=%B2%CB%B5%A5" target=_blank><FONT
color=red>菜单</FONT></A> <A href="http://search.yesky.com/search?q=%CA%E4%B3%F6"
target=_blank><FONT color=red>输出</FONT></A> <A
href="http://search.yesky.com/search?q=%CB%B3%D0%F2" target=_blank><FONT
color=red>顺序</FONT></A> 的全部文章 </DIV><!--广告代码开始-->
<SCRIPT>
var ad_cid;
if (window.location.search.substring(1) != "")
{
ad_cid = window.location.search.substring(1);
} else {
ad_cid = 412;
}
</SCRIPT>
<!--小通栏:c-scolumn顶部500*90--><SPAN id=span_ad1>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-scolumn.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
document.getElementById("ad1").innerHTML=document.getElementById("span_ad1").innerHTML;
document.getElementById("span_ad1").innerHTML="";
</SCRIPT>
<!--c-pip文章正文中间240*200--><SPAN id=span_ad3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -