×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    2

    Can I Access Native Contact list from J2ME Application

    Hi everyone,

    I'm new to both J2ME and nokia forum. Im currently workin on SMS Application for my final year project, which can encrypt and decrypt msgs. also it should be able to filter spam messages.
    I want to know whether it is possible to access the native contact list box from my J2ME application.
    bcz i have to allow the user to select the recepient from his/her "native contact list box" and send message using my application.

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,569

  3. #3
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Can I Access Native Contact list from J2ME Application

    Use PIM optional package. But first make sure that the devices in which you want to use In it this package is available or not ?

    Use the following code to check :

    String currentVersion = System.getProperty("microedition.pim.version " )

    if in device it is not supported then it will return null
    Last edited by honest_success; 2008-04-11 at 23:04. Reason: To give more info

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    9

    Re: Can I Access Native Contact list from J2ME Application

    Hi @all,

    i try to sign the contactlist access, but without certification i had to confirm two times till the startscreen of the midlet with contactlist appears. With certification i dont have to confirm, but i dont get the contactlist. Maybe there are problems with permissions?

    I have follow this suggestion:
    http://www.eclipse.org/forums/index....6624&#page_top

    but without success.


    This ist the Code:

    import java.io.IOException;
    import java.util.Enumeration;

    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.List;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import javax.microedition.pim.Contact;
    import javax.microedition.pim.ContactList;
    import javax.microedition.pim.PIM;

    import com.sun.lwuit.plaf.UIManager;
    import com.sun.lwuit.util.Resources;




    public class PIMMIDlet extends MIDlet implements CommandListener {

    private ContactList contList = null;

    private Enumeration contacts = null;

    private List mNameList;

    private Command mExitCommand = new Command("Exit", Command.EXIT,0);


    public PIMMIDlet() {
    // TODO Auto-generated constructor stub

    try{
    PIM pimInst = PIM.getInstance();
    contList = (ContactList) pimInst.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
    contacts = contList.items();
    }catch(Exception ex){
    return;
    }

    Resources theme;
    try {
    theme = Resources.open("res/LWUITtheme.res");
    UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }



    if(contacts == null)
    return;

    mNameList = new List("List of contacts", List.EXCLUSIVE);

    while(contacts.hasMoreElements()){
    Contact tCont = (Contact) contacts.nextElement();
    String[] nameValues = tCont.getStringArray(Contact.NAME, 0);
    String firstName = nameValues[Contact.NAME_GIVEN];
    String lastName = nameValues[Contact.NAME_FAMILY];
    String telName = tCont.getString(Contact.TEL, 0);



    mNameList.append(lastName+"," , null);
    mNameList.append(firstName+ "," , null);
    mNameList.append(telName+ "," , null);

    String currentVersion = System.getProperty("microedition.pim.version " );
    mNameList.append(currentVersion+ "," , null);

    }
    mNameList.addCommand(mExitCommand);
    mNameList.setCommandListener(this);


    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    // TODO Auto-generated method stub

    }

    protected void pauseApp() {
    // TODO Auto-generated method stub

    }

    protected void startApp() throws MIDletStateChangeException {
    // TODO Auto-generated method stub
    Display.getDisplay(this).setCurrent(mNameList);

    }

    public void commandAction(Command c, Displayable s) {
    // TODO Auto-generated method stub

    if( c == mExitCommand){
    try {
    destroyApp(true);
    } catch (MIDletStateChangeException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    notifyDestroyed();
    }

    }

    }


    Thx to all

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Can I Access Native Contact list from J2ME Application

    Quote Originally Posted by Nunu008 View Post
    try{
    PIM pimInst = PIM.getInstance();
    contList = (ContactList) pimInst.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
    contacts = contList.items();
    }catch(Exception ex){
    return;
    }
    By putting a "return" in a "catch" is a bad plan... you're hiding the problem. Find out what exceptions are getting caught, it might give you some clues as to the problem.

    Are you adding MIDlet-Permissions to your JAD?

    Graham.

  6. #6
    Registered User
    Join Date
    Jun 2010
    Posts
    9

    Re: Can I Access Native Contact list from J2ME Application

    thanks for the reply Graham,

    i have replace the return, there was not output.


    Quote Originally Posted by grahamhughes View Post
    By putting a "return" in a "catch" is a bad plan... you're hiding the problem. Find out what exceptions are getting caught, it might give you some clues as to the problem.

    Are you adding MIDlet-Permissions to your JAD?

    Graham.
    This is the problem, i can't find the pim permission in the signing -dialog of eclipse. I thought with the advice in
    http://www.eclipse.org/forums/index....6624&#page_top
    i could solve the problem.

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Can I Access Native Contact list from J2ME Application

    The permission setting should be "javax.microedition.pim.ContactList.read".

    Graham.

Similar Threads

  1. J2ME and contact list
    By morphine_titan in forum Mobile Java General
    Replies: 7
    Last Post: 2009-01-06, 07:49
  2. How to get information about available 802.11 access points in the J2ME application?
    By wzab in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2007-03-13, 02:00
  3. How to access the Phone Number from the J2ME Application
    By nuwan14d in forum Mobile Java General
    Replies: 1
    Last Post: 2003-09-04, 07:19
  4. Replies: 0
    Last Post: 2003-09-03, 12:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×