开发者

J2ME: How to import contact from contact list?

How do i add the functionality to import a contact number from address book/contact list and add it into an array?

Edit

If you have seen the advanced call m开发者_开发技巧anager app, it allows you to choose a contact from contact list and add to blacklist. I want to do same thing choose a contact from contact list and add to internal array.

Details:

Nokia N70

CLDC 1.1

MIDP 2.0


You need to check if the device supports JSR-75 to get PIM data access. Have a look at this link: http://jcp.org/en/jsr/detail?id=75


The specifications for the PIM API can be downloaded from the link provided by ruibm. Final release -> download page -> PIM Optional Package Specification. I'm not sure what more you could want other than a direct example....


there is 3 options to do so :

  1. using symbian c++ instead of j2me http://library.forum.nokia.com/index.jsp?topic=/Nokia_Symbian3_Developers_Library/GUID-B51A9A1F-8E80-4DF6-904A-7BD1A8976BBB.html
  2. making your own contact list using PIM api http://developers.sun.com/mobility/apis/articles/pim/index.html
  3. adding text field component with this attributes

    TextField num = new TextField("num", "", 20, TextField.PHONENUMBER);

now a command called add from contact is added to this text field and when chosen the default contact list will open and allow you to choose a number that will be written in your text field


try {
        verifyPIMSupport();
        PIM pimInst = PIM.getInstance();
        contList = (ContactList) pimInst.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
        enumContacts = contList.items();
        mainList = new List(":.:PHONE BOOK:.:", List.IMPLICIT);
        addCommand = new Command("ADD CONTACTS", Command.OK, 0);
        listCommand = new Command("LIST CONTACTS", Command.OK, 0);
        exitCommand = new Command("EXIT", Command.EXIT, 0);
        deleteCommand = new Command("DELETE ALL", Command.OK, 0);



       while (enumContacts.hasMoreElements()) {

            Contact tCont = (Contact) enumContacts.nextElement();
            String[] name_struct = tCont.getStringArray(Contact.NAME, 0);
            String firstname = name_struct[Contact.NAME_GIVEN];
            String lastname = name_struct[Contact.NAME_FAMILY];
            //String email = tCont.getString(Contact.EMAIL, 0);
           // String number = tCont.getString(Contact.TEL, 0);
            //String org = tCont.getString(Contact.ORG, 0);
            String person = "First Name:" + firstname+ "\n" + "Last Name:"
           + lastname ;
            //String person = "First Name:" + firstname + "\n" + "Last Name:"
           //+ lastname + "\n" + "N0:" + number + "\n" + "Email:" + email + "\n" + "Org:" + org;
            mainList.setFitPolicy(1);
            mainList.append(person, null);
        }
        mainList.addCommand(addCommand);
        mainList.addCommand(listCommand);
        mainList.addCommand(exitCommand);
        mainList.addCommand(deleteCommand);
        mainList.setCommandListener(this);

        display = Display.getDisplay(this);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜