×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    12

    what wrong in clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY )

    i want to get the information in contact ,my code is in the following,but it can not excute this sentence clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIS, PIM.READ_ONLY );,
    why ?? help me ??
    the code:
    import gov.nist.siplite.header.ContactList;

    import java.io.*;
    import java.util.Enumeration;

    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.pim.Contact;
    import javax.microedition.pim.PIM;
    import javax.microedition.pim.PIMException;
    import javax.microedition.pim.PIMList;

    import org.kxml.io.AbstractXmlWriter;
    import org.kxml.io.XmlWriter;

    public class f extends MIDlet implements CommandListener
    {

    private Display display;
    private Command exitCommand,okCommand;
    // private TextBox textbox;
    private Alert alert;
    public String tagTable[] = {
    "id",
    "firstname",
    "mun"
    };
    public f(){
    display = Display.getDisplay( this );


    alert=new Alert("alert","Are you start xml form contact?",null,AlertType.INFO);
    exitCommand = new Command( "Exit", Command.EXIT, 1 );
    okCommand=new Command("statxml",Command.OK,1);

    alert.addCommand(exitCommand);
    alert.addCommand(okCommand);
    alert.setCommandListener(this);
    }
    public void commandAction( Command c, Displayable d ){
    if( c == exitCommand )
    {
    destroyApp( false);
    notifyDestroyed();
    }else if(c==okCommand)
    {
    try
    {
    testXML();
    }catch( Exception e )
    {
    System.err.println( "Exception " + e );
    }
    }

    }

    protected void destroyApp( boolean unconditional )
    {

    }
    protected void pauseApp()
    {
    }

    protected void startApp()
    {
    display.setCurrent(alert);



    }

    private void log( String str )
    {
    System.out.println( str );
    }



    private void testXML() throws IOException
    {
    log("starting testxml");
    StringBuffer sb=new StringBuffer();


    try{
    PIM pim = PIM.getInstance();
    ContactList clist=null;
    try {
    log("start open");

    clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,
    PIM.READ_ONLY );
    log("end open");//the programe can not excute this sentence
    } catch(Exception e) {
    sb.append("{"+e+"}");
    }

    log("start congt");//the programe can not excute this sentence
    Contact contact = null;
    Enumeration items = ((PIMList) clist).items();
    while(items.hasMoreElements()) {

    contact = (Contact)(items.nextElement());
    int[] fields = contact.getFields();
    for(int i = 0; i < fields.length; i++)
    {
    int fieldIndex = fields[i];
    int dataType = ((PIMList) clist).getFieldDataType(fieldIndex);

    sb.append(" Field " + fieldIndex + ": "+((PIMList) clist).getFieldLabel(fieldIndex)+" - data type: " + dataType);
    sb.append("\n");

    for(int j = 0; j < contact.countValues(fieldIndex); j++)
    {
    int attr = contact.getAttributes(fieldIndex, j);
    try
    {
    sb.append("("+((PIMList) clist).getAttributeLabel(attr) + "): ");
    sb.append(contact.getString(fieldIndex, j));
    sb.append("\n");
    }catch(Exception e)
    {
    sb.append(":"+e+":");
    sb.append("\n");
    }
    }
    log(sb.toString());


    }

    }

    }catch(Exception pe) {
    pe.printStackTrace();
    }

    }

    }

    /* log( "Writing uncompressed XML to a string..." );
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    XmlWriter xw = new XmlWriter( new OutputStreamWriter( out ) );
    AbstractXmlWriter writer=( AbstractXmlWriter )xw;
    PIM pim = PIM.getInstance();
    ContactList list = null;
    try {
    log("starting ddc");
    list = (ContactList)pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY); log("ending ddc");//the programe can not excute this sentence
    }catch(PIMException pe){
    log("ddc catch");
    pe.printStackTrace();
    }catch(SecurityException se){
    log("ddc catch2");
    se.printStackTrace();
    }
    try {
    log("starting enumeratong");//the programe can not excute this sentence
    Enumeration items = ((PIMList) list).items();
    while(items.hasMoreElements()) {
    Contact contact = (Contact)items.nextElement();
    writer.startTag("id");
    writer.startTag( "firstname" );
    int field=contact.NAME ;
    int index=contact.getPreferredIndex( field) ;
    String temp=contact.getString(field, index);
    writer.write( temp );
    writer.endTag();
    writer.startTag( "mun" );
    int field2=contact.TEL;
    int index2=contact.getPreferredIndex( field) ;
    String temp2=contact.getString(field2, index2);
    writer.write( temp2);
    writer.endTag();
    writer.endTag();
    writer.close();
    }
    }catch(PIMException pe) {
    pe.printStackTrace();
    }catch(SecurityException se) {
    se.printStackTrace();
    }
    String str = new String( out.toByteArray() );
    log( "String length is " + str.length() );
    log( "String value is" );
    log( str );
    log( "Writing compressed XML to a string..." );
    out = new ByteArrayOutputStream();

    */

  2. #2
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: what wrong in clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY )

    What phone are you using? Are you getting an exception? If yes, which?

    Hartti

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    12

    Re: what wrong in clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY )

    Nokia_S40_DP20_SDK_1_1
    uncatch exception noclassdefounderror
    when i use sun wtk,the programe appear a message that says if i read the contact ,but i choose " yes" button ,there are nothing chance

  4. #4
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: what wrong in clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY )

    This API is not part of that SDK
    The release notes for that SDK mention

    Features:
    =========
    The SDK supports the following Java Specification Requests (JSRs):
    - Connected Limited Device Configuration 1.1 (JSR 139).
    - Mobile Information Device Profile 2.0 (JSR 118).
    - Java Technology for Wireless Industry (JSR 185).
    - Wireless Messaging API (JSR 120 v1.1).
    - Mobile Media API (JSR 135, audio only).
    - Bluetooth API (JSR 82).

    Hartti

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    12

    Re: what wrong in clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY )

    when i used System.out.println( System.getProperty("microedition.pim.version") ) ,return 1.0 ,not null.
    If the package is present, the method returns a version number and you're set. If the query returns null, the package is absent.
    i want to get contact that is in jsr75 library.

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: what wrong in clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY )

    Apparently there seems to be an implementation bug on the emulator you are using, which returns incorrect PIM version information, even if the SDK itself does not support it.
    As a workaround, please use newer Series 40 SDK, whcih contains the PIM API. (like Series 40 3rd Edition)

    Hartti

  7. #7
    Registered User
    Join Date
    Jun 2007
    Posts
    12

    Re: what wrong in clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY )

    i use the Series 40 3rd Edition,it appear the message :
    invalid application Delete?
    why ?? i can not get the contact

Similar Threads

  1. How to Prompt the user for IAP selection only if the wrong IAP is currently selected
    By kaiser_20 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-10-26, 15:19
  2. Replies: 0
    Last Post: 2005-02-16, 14:20
  3. whats wrong with this code?
    By Rx-lee in forum Symbian
    Replies: 4
    Last Post: 2004-03-25, 10:50
  4. wrong name
    By bwtoh in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2003-08-15, 13:22

Posting Permissions

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