×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Aug 2006
    Location
    PARIS, FRANCE
    Posts
    11

    PIM API: updating contact causes a reboot on 6270!

    using the PIM API (JSR) to add and update a contact, I have a serious problem: the Nokia 6270 reboots when I commit an updated contact!

    my source code is below.
    What is wrong? The contact is correctly added but not updated. The phone seems to reboot at the 2nd commit().
    But if I comment the setStringArray of address field, the contact is correctly updated!

    The version of 6270 is V 03.53 15-11-05 RM-56


    import java.util.Enumeration;

    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.pim.Contact;
    import javax.microedition.pim.ContactList;
    import javax.microedition.pim.PIM;
    import javax.microedition.pim.PIMException;
    import javax.microedition.pim.PIMItem;

    import uitest.Commands;
    import uitest.UiMIDlet;

    public class CreateAndUpdateContactScreen extends Form implements CommandListener
    {

    public CreateAndUpdateContactScreen()
    {
    super("Create and update Contact");
    addCommand(Commands.backCommand);
    setCommandListener(this);

    PIM pim = PIM.getInstance();
    ContactList contactList = null;
    Contact contactToAdd;
    Contact contactToSearch;
    Contact contactToUpdate;
    String addedContactId = "";
    try
    {
    contactList = (ContactList) pim.openPIMList(
    PIM.CONTACT_LIST, PIM.READ_WRITE);

    contactToAdd = contactList.createContact();

    setValues(contactToAdd,
    "http://www.voxmobili.com", null, null,
    null, null,
    null, "Paris", "75000", null,
    null, null, "Body",
    "FirstName102(c)", "LastName102(c)", "0606060606",
    "0101010101","0202020202");

    //add a contact
    contactToAdd.commit();

    addedContactId = contactToAdd.getString(Contact.UID, 0);

    append("Contact created successfully with phoneNumber=0606060606"+
    " and familyName=LastName102(c)\n") ;

    //Load added contact

    contactToSearch = contactList.createContact();

    contactToSearch.addString(Contact.UID, PIMItem.ATTR_NONE, addedContactId);

    Enumeration enumeration = contactList.items(contactToSearch);

    contactToUpdate = (Contact) enumeration.nextElement();

    //clean all fields of the added contact
    int[] fields = contactToUpdate.getFields();
    for (int fieldIndex = 0; fieldIndex < fields.length; fieldIndex++)
    {
    int field = fields[fieldIndex];
    if (Contact.REVISION != field && Contact.UID != field)
    {
    while(contactToUpdate.countValues(field) > 0)
    {
    contactToUpdate.removeValue(field, 0);
    }
    }
    }

    //reset fields
    setValues(contactToUpdate,
    "http://default.url.com", null, "rue",
    "po", "extra", "Ile de france",
    "Paris", "75000", "France",
    null, null, "Body",
    "FirstName102(r)", "LastName102(r)", "0606060606",
    "0101010101","0202020202");

    contactToUpdate.commit();

    append("Contact updated successfully with phoneNumber=0606060606"+
    " and familyName=LastName102(r)\n") ;

    }
    catch (Exception e)
    {
    append("Exception :" + e.getMessage() + "\n");
    }
    finally
    {
    if (contactList != null)
    {
    try
    {
    contactList.close();
    }
    catch (PIMException e)
    {
    append("can not close contactList");
    }
    }
    }
    }

    private void setValues(Contact a_Contact,
    String a_DefaultUrl, String a_HomeUrl, String a_Street,
    String a_PoBox, String a_ExtraAddress, String a_Region,
    String a_City, String a_PostalCode, String a_Country,
    String a_DefaultEmail, String a_HomeEmail, String a_Note,
    String a_FirstName, String a_LastName, String a_MobileNumber,
    String a_FaxNumber, String a_WorkNumber)
    {
    String[] name = new String[a_Contact.getPIMList().stringArraySize(Contact.NAME)];
    if (a_LastName != null && a_Contact.getPIMList().isSupportedArrayElement(Contact.NAME, Contact.NAME_FAMILY))
    {
    name[Contact.NAME_FAMILY] = a_LastName;
    }
    if (a_FirstName != null && a_Contact.getPIMList().isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN))
    {
    name[Contact.NAME_GIVEN] = a_FirstName;
    }
    a_Contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);



    if (a_Contact.getPIMList().isSupportedField(Contact.ADDR) &&
    a_Contact.getPIMList().isSupportedAttribute(Contact.ADDR, Contact.ATTR_HOME))
    {
    String[] addr = new String[a_Contact.getPIMList().stringArraySize(Contact.ADDR)];

    if (a_Contact.getPIMList().isSupportedArrayElement(Contact.ADDR, Contact.ADDR_POBOX))
    {
    addr[Contact.ADDR_COUNTRY] = a_PoBox;
    }
    if (a_Contact.getPIMList().isSupportedArrayElement(Contact.ADDR, Contact.ADDR_EXTRA))
    {
    addr[Contact.ADDR_COUNTRY] = a_ExtraAddress;
    }
    if (a_Contact.getPIMList().isSupportedArrayElement(Contact.ADDR, Contact.ADDR_COUNTRY))
    {
    addr[Contact.ADDR_COUNTRY] = a_Country;
    }
    if (a_Contact.getPIMList().isSupportedArrayElement(Contact.ADDR, Contact.ADDR_REGION))
    {
    addr[Contact.ADDR_LOCALITY] = a_Region;
    }
    if (a_Contact.getPIMList().isSupportedArrayElement(Contact.ADDR, Contact.ADDR_POSTALCODE))
    {
    addr[Contact.ADDR_POSTALCODE] = a_PostalCode;
    }
    if (a_Contact.getPIMList().isSupportedArrayElement(Contact.ADDR, Contact.ADDR_LOCALITY))
    {
    addr[Contact.ADDR_POSTALCODE] = a_City;
    }
    if (a_Contact.getPIMList().isSupportedArrayElement(Contact.ADDR, Contact.ADDR_STREET))
    {
    addr[Contact.ADDR_STREET] = a_Street;
    }

    a_Contact.addStringArray(Contact.ADDR, Contact.ATTR_HOME, addr);
    }


    if (a_Contact.getPIMList().isSupportedField(Contact.TEL))
    {
    if (a_MobileNumber != null && a_Contact.getPIMList().isSupportedAttribute(Contact.TEL, Contact.ATTR_MOBILE))
    {
    a_Contact.addString(Contact.TEL,
    Contact.ATTR_MOBILE,
    a_MobileNumber);
    }
    if (a_FaxNumber != null && a_Contact.getPIMList().isSupportedAttribute(Contact.TEL, Contact.ATTR_FAX))
    {
    a_Contact.addString(Contact.TEL,
    Contact.ATTR_FAX,
    a_FaxNumber);
    }
    if (a_WorkNumber != null && a_Contact.getPIMList().isSupportedAttribute(Contact.TEL, Contact.ATTR_WORK))
    {
    a_Contact.addString(Contact.TEL,
    Contact.ATTR_WORK,
    a_WorkNumber);
    }
    }

    if (a_Note != null &&
    a_Contact.getPIMList().isSupportedField(Contact.NOTE))
    {
    a_Contact.addString(Contact.NOTE,
    Contact.ATTR_NONE,
    a_Note);
    }
    }

    public void commandAction(Command command, Displayable displayable)
    {
    if (command == Commands.backCommand)
    {

    }
    }

    }

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    20

    Re: PIM API: updating contact causes a reboot on 6270!

    Hi Suzior,

    Are you talking about SIM contacts or Phone contacts??
    In case of my application ....If i perform some updation on sim contact then phone reboots but not while updating a phone contact....

    Thanks

  3. #3
    Registered User
    Join Date
    Aug 2006
    Location
    PARIS, FRANCE
    Posts
    11

    Re: PIM API: updating contact causes a reboot on 6270!

    It was a phone contact

    What is your phone model?

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: PIM API: updating contact causes a reboot on 6270!

    hi p_joon,
    i've posted link to tech lib note about that issue with PIM/6270:
    http://discussion.forum.nokia.com/fo...ad.php?t=93239
    regards,
    Peter

  5. #5
    Registered User
    Join Date
    Aug 2006
    Location
    PARIS, FRANCE
    Posts
    11

    Re: PIM API: updating contact causes a reboot on 6270!

    the people having the following phones could test my application to see whether their telephone reboots too:
    Nokia 6270 firmware version : V 03.53 15-11-05 RM-56.
    Nokia 6280 firmware version : V 03.81 09-05-06 RM-78.
    Nokia 6111 firmware version : V 03.45 29-11-05 RM-82.

    Here the link of the application:
    http://qhonline.free.fr/j2me/testBug.jad

    To test, select the first item to update a contact.

    Thanks in advance for your feedback.

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    43

    Re: PIM API: updating contact causes a reboot on 6270!

    Hi all,

    when i run this code it works fine on wtk emulator but it gives me

    "Application Error" while running on Nokia 7360..

    I already check the MIDP and CLDC version. It is same as what the device is supporting....


    here is my code ..It simply add one contact....




    Code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.pim.*;
    import java.util.Enumeration;
    
    
    public class AddContact extends MIDlet implements CommandListener,Runnable
    {
    	Form form;
    	Display display;
    	Command exit;
    	Command add;
    	Alert alert;
    	public Thread th;
    	private boolean quit = false;	
    
    	public AddContact()
    	{
    
    	display = Display.getDisplay(this);
    
    	form = new Form("Check PIM support");
    	exit = new Command("Exit",Command.EXIT,1);
    	add = new Command("Add Contact",Command.OK,1);
    
    	alert = new Alert("Add Contact","Contact Added Succesfully",null,null);
    	alert.setTimeout(Alert.FOREVER);
    	
    	form.addCommand(add);	
    	form.addCommand(exit);
    	form.setCommandListener(this);
    	
    	}
    
    	public void startApp() 
    
    	{
    		display.setCurrent(form);
    		th = new Thread(this);   
    
    	}
        
    	public void pauseApp() 
    	{
    	}
        
    	public void destroyApp(boolean unconditional) 
    	{
    	}
    
    
    	 public void commandAction(Command c, Displayable d) {
    		
    		 if(c==exit)
    			{
    			
    			destroyApp(false);
                    	notifyDestroyed();
    			}
    		else if (c == add)
    			{
    				if(!quit)
    				{
    				th.start();
    				display.setCurrent(alert);
    				}
    			}
    		}
    
    	public void quit()
    	{
    	quit = true;
    	}
    
    	public void run()
    	{	
    	while (!quit)
    		{
    		try
    		{
    		PIM pim = PIM.getInstance();
    		ContactList cl = null;
    		Contact new_contact = null;
    		Enumeration read_contact = null;
    		String final_no="";
    		
    
    		try 
    		{
    			cl = (ContactList)pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_WRITE);
    
    		}
    		catch(PIMException pime)
    		{
    			Alert alert_1 = new Alert("Error","Error Accessing Database"+pime,null,null);
    			alert_1.setTimeout(Alert.FOREVER);
    			alert_1.setType(AlertType.ERROR);
    			display.setCurrent(alert_1);
    		}
    
    		catch(SecurityException se)
    		{
    			Alert alert_2 = new Alert("Error","Security Error"+se,null,null);
    			alert_2.setTimeout(Alert.FOREVER);
    			alert_2.setType(AlertType.ERROR);
    			display.setCurrent(alert_2);
    		}
    
    		new_contact = cl.createContact();
    
    
    
    		new_contact.addString(Contact.TEL,Contact.ATTR_HOME,"123456");
    		new_contact.addString(Contact.FORMATTED_NAME,Contact.ATTR_NONE,"AasdD");
    		new_contact.addString(Contact.TEL,Contact.ATTR_MOBILE,"2634465");
    		new_contact.addString(Contact.TEL,Contact.ATTR_FAX,"+91 7834465");
    		new_contact.addString(Contact.TEL,Contact.ATTR_PAGER,"7034465");
    		new_contact.addString(Contact.TEL,Contact.ATTR_MOBILE,"9234465");
    
    		try
    		{
    			new_contact.commit();
    		}
    
    		catch(PIMException piem)
    		{
    				Alert alert_4 = new Alert("Error","Error while saving  Data"+piem,null,null);
    				alert_4.setTimeout(Alert.FOREVER);
    				alert_4.setType(AlertType.ERROR);
    				display.setCurrent(alert_4);
    
    		}
    
    		try
    		{
    			cl.close();
    		}
    		catch(PIMException piem)
    		{
    			Alert alert_5 = new Alert("Error","Error Closing Application"+piem,null,null);
    				alert_5.setTimeout(Alert.FOREVER);
    				alert_5.setType(AlertType.ERROR);
    				display.setCurrent(alert_5);
    		}
    
    		}
    		catch (Exception e)
    		{
    			Alert alert_4 = new Alert("Error","Error on first try"+e,null,null);
    			alert_4.setTimeout(Alert.FOREVER);
    			alert_4.setType(AlertType.ERROR);
    			display.setCurrent(alert_4);
    		}
    
    
    		quit();
    		}
    	}
    }


    Any help ?...

    regards
    Pravin

  7. #7
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: PIM API: updating contact causes a reboot on 6270!

    hi,
    at what point you're getting that exception with your code?
    thanks,
    Peter

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    43

    Re: PIM API: updating contact causes a reboot on 6270!

    Hi,

    I do not get any exception just one Alert Like "Application error"
    comes while i run application....

    and one more thing when try to run he code given on the top of the page by suzier then it gives me " Exception :error"

    means it throws an exception on first try block....

    I think there is something wrong when the application try to open PIMlist...

    Is there any setting i have to do in mobile before running application......




    regards
    Pravin

  9. #9
    Registered User
    Join Date
    Apr 2007
    Location
    Estonia, Tallinn
    Posts
    8

    Exclamation Re: PIM API: updating contact causes a reboot on 6270!

    Hi.
    Add
    Code:
    try {
        Thread.sleep(400);
    } catch (InterruptedException ie) {
        // Ignore
    }
    right before second commit().

    I add this code before each commit() method as workaround for Nokia's weird synchronization issue. Timeout parameter is varied from 400 to 2000ms using different models. The most issued device I met is 6131.
    This weird bug still exists on all S40 devices with the latest SW versions known for today.

    Cheers,
    Gennady

Similar Threads

  1. PC Suite error: (Code: Init IMediaControl2) HELP?!
    By chunkyspudmonkey in forum General Development Questions
    Replies: 30
    Last Post: 2014-07-15, 05:44
  2. pim and updating a contact ?? help
    By dakoz in forum Mobile Java General
    Replies: 5
    Last Post: 2010-07-23, 09:42
  3. PIM Api and fromSerialFormat()
    By divyas in forum Mobile Java General
    Replies: 10
    Last Post: 2009-10-28, 11:47
  4. PIM API and Timestamp
    By divyas in forum Mobile Java General
    Replies: 1
    Last Post: 2006-09-06, 23:33
  5. PIM API 和FILECONNECTION API 范例下载
    By dennisdeng in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 2
    Last Post: 2005-09-13, 08:41

Posting Permissions

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