




已阅读5页,还剩18页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
moto手机开发的一些问题汇总1,怎么样程序知道是运行在模拟器上还是在手机上 看IMEI号。一般手机按*#06#就可得到imei码,每个手机是唯一的。 public void paint(Graphics g) g.drawString(Phone Parameter:,0, 0, 16|4); g.drawString(IMEI:,0, 30,16|4); g.drawString(System.getProperty(phone.imei),0, 60,16|4); g.drawString(Network Parameter:,0, 90, 16|4); g.drawString(MCC:+System.getProperty(phone.mcc),0, 120,16|4); g.drawString(MNC:+System.getProperty(phone.mnc),0, 150, 16|4); g.drawString(LAI:+System.getProperty(phone.lai),0, 180, 16|4); g.drawString(CID:+System.getProperty(phone.cid),0, 210, 16|4); 2 看别人的game源代码时,找不到resource(图片)的原因, 如果你还没有添加一个叫做J2ME_RESOURCE_DIR的新的环境变量的话,建立他,具体步骤如下: win98下:编辑c:autoexec.bat文件,加入set J2ME_RESOURCE_DIR=你的工程目录,重起系统。 win2k下:我的电脑-属性-高级-环境变量-系统-添加-名称:J2ME_RESOURCE_DIR 内容:你的工程目录 配好后,每当你在jcreator中打开时,就自动转向你的J2ME_RESOURCE_DIR所指定的目录 3 四级灰度的颜色值怎么表示? private final static int WHITE_COLOR = 0x00FFFFFF; private final static int LIGHT_GRAY = 0x; private final static int DARK_GRAY = 0x; private final static int BLACK_COLOR = 0x; 4 关于开发工具 MotoJ2SDK是为摩托罗拉388手机定制的命令行开发工具包,当然也可与IDE开发工具集成从而方便用户的开发。其中可以集成的开发环境包括:CodeWarrior, JCreator等。 另外SUN公司还提供了Java的开发工具,J2ME Wireless Tookit是为无线手持设备(MDIP)定制的简易开发工具包。如果用户需要更强的IDE开发环境,那么请选用Forte for Java CE。目前SUN公司提供的开发工具中暂时还没有388的模拟器。 Java 2 SDK 1.3是必备的,它提供开发、测试和运行Java程序的平台 本人推荐jcreator. 5 Jcreater+MotoJ2SDK的配置与使用心得 假设安装路径如下: JCreator D:Program FilesXinox SoftwareJCreator LE motoj2sdk D:Motoj2sdk JDK D:jdk1.3.1 注意:要先击活模拟环境,运行D:MotoJ2SDKgenericscriptsrunConstructor.bat 选择手机型号,选择语言,选择normal, 再创建。 启动Jcreater之后我的配置如下: 第一步 选择 Configure-Options-JDK Profiles 注意:一定新建 profile and select “D:jdk1.3.1” 将名字改为“J2ME 388” Add classes path “D:Motoj2sdklib” Add documentation path “D:Motoj2sdkdocs” 分别将后加的两行移到最上方. 第二步 选择 Configure-Options-JDK Tools 选择Complier 选中 and edit it. 将 parameters 变为 -O -bootclasspath D:/motoj2sdk/lib $JavaFiles 第三步 选择 Configure-Options-Tools 点击“New”选择 DOS command 名字为“Preverifier” 将 arguments 换为 d:Motoj2sdkbinpreverifier.exe -classpath d:Motoj2sdklib -d . . 将 initial directory 变为 “$PrjDir” 第四步 按上面的方法在New一个 DOS command 名字:“Run Emulator” 将 arguments 换成 “java -Djava.library.path=d:/MotoJ2SDK/lib -classpath d:/MotoJ2SDK/bin/Emulator.jar;d:/MotoJ2SDK/ConfigTool.jar com.mot.tools.j2me.emulator.Emulator -classpath$PrjDir;d:/MotoJ2SDK/lib -deviceFile d:/MotoJ2SDK/bin/resources/ps javax.microedition.midlet.AppManager $CurClass -JSA 1 1” 将 initial directory 换成 “d:Motoj2sdkbin” 第五步 New DOS command “Create Jar” Change arguments to “$JavaHomebinjar.exe cvfM $PrjName.jar META-INFMANIFEST.MF *.CLASS *.png” Change initial directory to “$PrjDir” NOTE: You must add META-INFMANIFEST.MF in the project NOTE: You must change the directory “com/mot/project/*.CLASS” when you create your project. NOTE: If you have resource files, you should also add these files into jar file, 1 folder is not necessary. ok!编辑工具配置完毕! 新建一个工程选择Empty Project 再取一个名字 比如:test 则jcreater自动在你的工作目录中生成目录test 再new一个file选择java File 写好你的原代码,保存 如:test.java 在Project中 选add file 然后选中你刚才的test.java 注意:不要有package ; 编译tools中的Preverifier进行预先审核tools中的Run Emulator进行模拟 test.java 的例子:功能是捕捉键盘输入的ascII吗。 import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class test extends MIDlet implements CommandListener /* * The screen for this MIDlet */ private KeyEventsDemoCanvas myCanvas; /* * Reference to current Display */ private Display myDisplay; /* * Command to make sure soft key is not a key event */ private Command okCommand = new Command(OK, Command.OK, 1); test() myDisplay = Display.getDisplay(this); myCanvas = new KeyEventsDemoCanvas(); myCanvas.addCommand(okCommand); myCanvas.setCommandListener(this); /* * Do nothing if a command is fired */ public void commandAction(Command c, Displayable s) /* * Start the MIDlet */ protected void startApp() throws MIDletStateChangeException myDisplay.setCurrent(myCanvas); /* * Pause the MIDlet */ protected void pauseApp() /* * Called by the framework before the application is unloaded */ protected void destroyApp(boolean unconditional) /* * The screen for this application */ class KeyEventsDemoCanvas extends Canvas /* * Background color (i.e. the color of the screen) */ public final int BACKGROUND_COLOR = 0xFFFFFF; / white /* * Foreground color (i.e. the color of the rectangles) */ public final int FOREGROUND_COLOR = 0x; / black /* * Last key that was pressed */ private int lastKey; /* * Paint the screen */ public void paint(Graphics g) /* * Clear the screen */ g.setColor(BACKGROUND_COLOR); g.fillRect(0, 0, getWidth(), getHeight(); /* * Paint the message */ g.setColor(FOREGROUND_COLOR); g.drawString(Press a key!, 0, 0, Graphics.TOP | Graphics.LEFT); if (lastKey != 0) g.drawString(Key Code: + lastKey, 0, g.getFont().getHeight(), Graphics.TOP | Graphics.LEFT); try g.drawString(Action: + getGameAction(lastKey), 0, 2 * g.getFont().getHeight(), Graphics.TOP | Graphics.LEFT); g.drawString(Key Name: + getKeyName(lastKey), 0, 3 * g.getFont().getHeight(), Graphics.TOP | Graphics.LEFT); catch (Exception e) / ignore since alphabet keys will throw this exception /* * Handle key press */ public void keyPressed(int keyCode) lastKey = keyCode; repaint(); /* * Demonstrate keyRepeated events */ public void keyRepeated(int keyCode) System.out.println(Key repeated + keyCode); 6怎么在主类中响应按钮消息,这个对于切换显示很有帮助。 /文件名 LWTDemoMIDlet.java import com.motorola.lwt.*; import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class LWTDemoMIDlet extends MIDlet implements CommandListener class ButtonScreen extends ComponentScreen public ButtonScreen() / Add a button to the screen Button b1 = new Button(b); /下面的代码是设定按钮高度 b1.setBottomEdge(Component.HEIGHT, 30); /下面的代码是设定按钮宽度 b1.setRightEdge(Component.WIDTH,80); /下面的代码是设定按钮y坐标,a相对屏幕最上 b1.setTopEdge(Component.SCREEN_TOP, 10); /下面的代码是设定按钮x坐标相对前一个控件 b1.setLeftEdge(Component.PREVIOUS_COMPONENT_RIGHT, 30); add(b1); / Add another button to the screen Button b2 = new Button(点我就行了) public void componentActuated() Show(); ; / Extend the right edge to the right edge of the screen b2.setRightEdge(Component.WIDTH, 220); b2.setBottomEdge(Component.HEIGHT, b2.getPreferredHeight() * 2); add(b2); Command next = new Command(Next, Command.OK, 1); Command prev = new Command(Previous, Command.BACK, 1); addCommand(next); addCommand(prev); ; ButtonScreen screens = new ButtonScreen(); public LWTDemoMIDlet() screens.setCommandListener(this); protected void startApp() throws MIDletStateChangeException Display.getDisplay(this).setCurrent(screens); protected void pauseApp() protected void destroyApp(boolean unconditional) throws MIDletStateChangeException public void Show() System.out.println(Get it on main Class); public void commandAction (Command c, Displayable d) if (screens = d) / Found it, check which command was triggered if (c.getCommandType() = Command.BACK) System.out.println(back); else if (c.getCommandType() = Command.OK) System.out.println(ok); return; 7 中文显示,存储问题。把中文写入rms中,再读出。 public void openRMS() try recordStore = RecordStore.openRecordStore(RECORD_STORE,true); catch(Exception e)db(e.toString(); System.out.println(RMS opened successfully!); public void closeRMS() try recordStore.closeRecordStore(); catch(Exception e) db(e.toString(); System.out.println(RMS closed successfully!); public void deleteRMS() if(recordStore.listRecordStores() != null) try recordStore.deleteRecordStore(RECORD_STORE); catch(Exception e) db(e.toString(); System.out.println(RMS deleted successfully!); public void writeRMS(int id,String str ) / String ws; / userId = inputScreen.f1.getText(); System.out.println(check input: +str); / ws=new String(userId+ +score); writeStream(id,str); System.out.println(RMS writed successfully!); public void writeStream(int id,String sData) try ByteArrayOutputStream strmBytes = new ByteArrayOutputStream(); DataOutputStream strmDataType = new DataOutputStream(strmBytes); byte record; strmDataType.writeUTF(sData); strmDataType.flush(); record = strmBytes.toByteArray(); if(recordStore.getNumRecords()=2) recordStore.setRecord(id,record,0,record.length); else recordStore.addRecord(record,0,record.length); strmBytes.reset(); strmBytes.close(); strmDataType.close(); catch(Exception e) db(e.toString(); public void readRMS() try byte data = new byte50; ByteArrayInputStream strmBytes = new ByteArrayInputStream(data); DataI
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 天府新区航空旅游职业学院《原子物理学》2023-2024学年第二学期期末试卷
- 五星级宾馆工程部培训课件
- 2025年个人果园承包合同
- 2025租房合同高清范文
- 2025年短期用工合同模板
- 2025商业综合体租赁合同书
- 2025大型设备租赁合同
- 2025大连商品房购房合同范本
- 2025创意合作项目合同
- 2025年县级公路与排水系统建设项目合同协议书模板
- 渠道施工课件
- 世界500强人力资源总监管理笔记
- 数字化时代的金融监管
- 《疯狂动物城》全本台词中英文对照
- 金融风险传染性研究
- 电力出版社材料力学课后习题答案
- 成人体外心肺复苏专家共识(2023版)解读
- 医院食堂运营食堂餐饮服务投标方案(技术标)
- 医院耗材SPD解决方案(技术方案)
- 岗位调动确认书
- 光伏电站事故处理规程
评论
0/150
提交评论