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

📄 dialermidlet.java

📁 这是一个很小的手机应用程序源代码 可以用来查看手机电话本等
💻 JAVA
字号:
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.io.*;/******************************************************************************* * Description: This is a sample application to demonstrate the usage of * the TextField.PHONENUMBER and the platformRequest("tel:"+phoneNumber). * Editing the phone number should also allow the user to select * a number from the mobile phone book. * * File: DialerMIDlet.java * * Created by: Philippe Villeneuve for SonyEricsson * * COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2003. * * The software is the copyrighted work of Sony Ericsson Mobile Communications AB. * The use of the software is subject to the terms of the end-user license * agreement which accompanies or is included with the software. The software is * provided "as is" and Sony Ericsson specifically disclaim any warranty or * condition whatsoever regarding merchantability or fitness for a specific * purpose, title or non-infringement. No warranty of any kind is made in * relation to the condition, suitability, availability, accuracy, reliability, * merchantability and/or non-infringement of the software provided herein. ******************************************************************************/public class DialerMIDlet extends MIDlet implements CommandListener {  Form dialerForm;  Display display;  Command dialCommand = new Command("Call", Command.OK, 2);  Command exitCommand = new Command("Exit", Command.EXIT, 1);  TextField phoneNumber;    public DialerMIDlet() {    try {      phoneNumber = new TextField("Phone #", "", 20, TextField.PHONENUMBER);/* * The same line as the precedent, but this time pre-initialised. This way, the  * use may avoid re-typing the same string as (s)he test the application. For the * purpose of this code sample, it is better not to feed a phone number as the * user may not notice that when the field is empty, the application propose to  * read from the phone book. * *    phoneNumber = new TextField("Phone #", "0731112222", 20, TextField.PHONENUMBER); */          }    catch (IllegalArgumentException exp) {      System.out.println("Misformed phone number.");    }    display = Display.getDisplay(this);  }    public void startApp() {    if (dialerForm == null) {      dialerForm = new Form("Dialer");      dialerForm.addCommand(exitCommand);      dialerForm.addCommand(dialCommand);      dialerForm.setCommandListener(this);      dialerForm.append(phoneNumber);    }    display.setCurrent(dialerForm);  }    public void pauseApp() {}  public void destroyApp(boolean unconditional) {}    public void commandAction(Command c, Displayable s) {    if (c == exitCommand) {      destroyApp(false);      notifyDestroyed();    }    if (c == dialCommand) {      try {        platformRequest("tel:"+phoneNumber.getString());      }      catch (ConnectionNotFoundException exp) {        // This occur if the device does not support this type of operation.        System.out.println("Error calling.");      }    }  }}

⌨️ 快捷键说明

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