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

📄 testpimmidlet.java~50~

📁 一段通过PIM取电话簿的程序
💻 JAVA~50~
字号:
import javax.microedition.pim.*;import javax.microedition.lcdui.*;import javax.microedition.midlet.*;import java.util.Enumeration;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class testPimMidlet extends MIDlet implements CommandListener{  Display display;  static testPimMidlet instance;  Form frmPIM;  Command cmdCancel;  public testPimMidlet(){    String v = System.getProperty("microedition.pim.version");    instance = this;    frmPIM = new Form("testPIM");    if(v !=null)      frmPIM.append("yes");    else      frmPIM.append("no");    cmdCancel = new Command("退出",Command.OK,Command.OK);    frmPIM.addCommand(cmdCancel);    frmPIM.setCommandListener(this);  }  protected void startApp() throws javax.microedition.midlet.MIDletStateChangeException {    /**@todo Implement this javax.microedition.midlet.MIDlet abstract method*///    PIM test = PIM.getInstance();//    System.out.println("test="+test);//    ContactList cl = null;    try {//      cl = (ContactList)test.openPIMList(PIM.READ_ONLY,//           PIM.READ_ONLY );//      System.out.println("cl="+cl);//      //user contact//      Enumeration enum = cl.items();//      System.out.println("enum="+enum);//    //  System.out.println("more element="+enum.hasMoreElements());//      if(enum.hasMoreElements()){//        Contact contact = (Contact)enum.nextElement();//        frmPIM.deleteAll();//        frmPIM.append("have element");//      }else{//        frmPIM.deleteAll();//        frmPIM.append("no element");//      }      String[] names = PIM.getInstance().listPIMLists(PIM.CONTACT_LIST);      for ( int i = 0; i < names.length; i++)      {      System.out.println("Address book name: " + names);      ContactList list = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY, names[i]);      frmPIM.append(names[i]);      Contact contact;      for (Enumeration e = list.items(); e.hasMoreElements();)      {      contact = (Contact) e.nextElement();      String name = contact.getString(Contact.NAME,0);      String tel = contact.getString(Contact.TEL,0);      frmPIM.append(name);      frmPIM.append(tel);      //db.put(contactName(contact), contact);     // System.out.println("Contact name = " + contactName(contact));     // count++;      }      list.close();      contact = null;      }    }    catch (PIMException ex) {      //no contact be used    //  frmPIM.deleteAll();      frmPIM.append("PIMExcepiton");    }catch(SecurityException sex){      //the application is not allowed to access the list     // frmPIM.deleteAll();      frmPIM.append("SecurityException");    }    display = Display.getDisplay(this);    display.setCurrent(frmPIM);  }  protected void pauseApp() {    /**@todo Implement this javax.microedition.midlet.MIDlet abstract method*/  }  protected void quitApp(){    try {      destroyApp(true);      instance.notifyDestroyed();      instance = null;    }    catch (Exception ex) {      ex.printStackTrace();    }  }  protected void destroyApp(boolean parm1) throws javax.microedition.midlet.MIDletStateChangeException {    /**@todo Implement this javax.microedition.midlet.MIDlet abstract method*/  }  public void commandAction(Command c,Displayable d){    if(d== frmPIM&& c==cmdCancel)      quitApp();  }}

⌨️ 快捷键说明

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