×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Nov 2012
    Location
    Lahore, Pakista
    Posts
    58

    PIM Issue & Sim Contacts read problem

    I want some Nokia Champ or Pro Developer to answer my Question as I have already been given so many suggestions and solutions but none of them worked. I have designed a j2me application which reads contacts from SIM and Phone memory after selecting options (From Sim, From Phone) individually. I have problems in here which I think are from the Nokia Devices as I tried that over almost 30 to 50 mobile sets.

    Problem is defined here
    1- When reading contacts either from SIM or Phone for the very first time of the application is installed/Downloaded/Put into the phone, when I try to read contacts the application hangs there no matter how long I wait it doesn't work, and when I restart the application, it works fine. Now I want to ask whether this issue is genuinely in Nokia devices? because I tried to put even simplest lines of code to read contacts but on the very first time it always hang. Point to note that my application is signed from VeriSign and if run without certificate it works fine as it doesn't ask me for "Always" permission. So what I concluded is that when I select always permissions, it either unable to set those permissions at the first time or what else? I am posting the simplest code I used as I was suggested by some Nokia Developer to put code in Thread so did I but the same issue persists, and it actually messing up my development of the application. I need to resolve this issue at any cost. Here is the code

    Code:
    public void ReadContacts extends Thread{
                public void run(){
           try {
                boolean doWrite = true;
                contacts.removeAllElements();
                pim = PIM.getInstance();
                String lists[] = pim.listPIMLists(PIM.CONTACT_LIST);
                for (int i = 0; i < lists.length; i++) {
                    //code for custom backup operation
                    if (customCode == 1 && i == 0) {
                        continue;
                    } else if (customCode == 0 && i > 0) {
                        continue;
                    }
                    clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY, lists[i]);
                    Enumeration cenum = clist.items();
                    while (cenum.hasMoreElements()) {
                        Contact c = (Contact) cenum.nextElement();
                        ContactDTO contact = new ContactDTO();
                        parseContactInfo(c, contact);
                        if (customCode == 2 && i > 0) {
                            Enumeration cenum1 = contacts.elements();
                            ContactDTO contact1;
                            while (cenum1.hasMoreElements()) {
                                contact1 = (ContactDTO) cenum1.nextElement();
                                if (contact1.getName().equals(contact.getName())) {
                                    if (contact1.getCodedString().equals(contact.getCodedString())) {
                                        doWrite = false;
                                        break;
                                    } else {
                                        doWrite = true;
                                    }
                                }
                            }
                        }
                        if (doWrite) {
                            contacts.addElement(contact);
                        }
                    }
                    clist.close();
                }
            } catch (Exception e) {
          }
       }
    }
    ---of course I have this code modified according to my needs, but even if I use it's simplest form(just reading part) it still behaves like that, so don't ask me to put that code as you can understand what I mean, thanks---

    [Edit: Removed second part to put as new thread thinking that people may get interest to that too being individual and prominent]
    Last edited by saqibatiq; 2013-03-13 at 06:47.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Re: PIM Issue & Sim Contacts read problem

    No concrete suggestion, just some ideas: Have you played with on-device-debugging to find the line of code? Have you played around with Thread.yield()?

  3. #3
    Registered User
    Join Date
    Nov 2012
    Location
    Lahore, Pakista
    Posts
    58

    Re: PIM Issue & Sim Contacts read problem

    Quote Originally Posted by traud View Post
    No concrete suggestion, just some ideas: Have you played with on-device-debugging to find the line of code? Have you played around with Thread.yield()?
    What I know is the issue comes when for the very first time it tries to open the PIM list and there it hangs, afterwards, as no permissions are asked because I have selected that at very first time start, so it works fine. I don't know why does it happens? and thing to note is that I tried it over Samsung GT-E2252 where it works absolutely fine. What I wanted to know was is there anyone else who had similar issue with hanging while reading contacts?

    and as far as for second issue, I don't know why only old devices cause this error? talking about debugging on device if I had code issue it shouldn't have run over a number of devices too...

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Re: PIM Issue & Sim Contacts read problem

    Sometimes, knowing the concrete line of code which hangs, brings up an idea to work-around this issue. Your descriptions sounds like a bug from Nokia. Well, now is the phase to workaround it. Perhaps some calls create a new thread which is still waiting. i never read about your issue, and that issue should be quite common.

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

    Re: PIM Issue & Sim Contacts read problem

    Is it possible that something on another Thread is calling Display.setCurrent()... and that the new Displayable is hiding the permission dialogue?

    Is this problem occuring on S40 or S60 devices?

  6. #6
    Registered User
    Join Date
    Nov 2012
    Location
    Lahore, Pakista
    Posts
    58

    Re: PIM Issue & Sim Contacts read problem

    Quote Originally Posted by traud View Post
    Sometimes, knowing the concrete line of code which hangs, brings up an idea to work-around this issue. Your descriptions sounds like a bug from Nokia. Well, now is the phase to workaround it. Perhaps some calls create a new thread which is still waiting. i never read about your issue, and that issue should be quite common.
    Yes this issue need to be checked, I don't know whether someone else face same problem or not but on the latest devices I used with "Always" permission, that is on most of the new devices, behave like this.

  7. #7
    Registered User
    Join Date
    Nov 2012
    Location
    Lahore, Pakista
    Posts
    58

    Re: PIM Issue & Sim Contacts read problem

    Quote Originally Posted by grahamhughes View Post
    Is it possible that something on another Thread is calling Display.setCurrent()... and that the new Displayable is hiding the permission dialogue?

    Is this problem occuring on S40 or S60 devices?
    Does that effect anyway? I mean if I have a separate thread for permissions and if hiding dialog, it shouldn't work further until I give permissions. And as I do give permissions it hangs there no matter what I do or how, the very first time it has to hang. And this issue occurring over S40 devices as s60 devices (most of them) do not provide always permission. And on other models than Nokia I have no such issue, which means there is a bug in Nokia s40 devices.

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

    Re: PIM Issue & Sim Contacts read problem

    Ah, sorry, I didn't read all the original details correctly. I've seen an issue before (on a Sony Ericsson device) where the app appeared to hang opening a network connection, which turned out to be because it was waiting for user permission, but the dialogue was hidden behind the application and the user could not see or interact with it, so could not give the permission the app was waiting for.

    I now realize that in your case it should not be asking for permission, right?

    Can only echo traud's suggestion to use on-device debug and find out exactly which API call is hanging.

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Re: PIM Issue & Sim Contacts read problem

    So, have you tried on-device debugging already?

  10. #10
    Registered User
    Join Date
    Nov 2012
    Location
    Lahore, Pakista
    Posts
    58

    Re: PIM Issue & Sim Contacts read problem

    Quote Originally Posted by grahamhughes View Post
    Ah, sorry, I didn't read all the original details correctly. I've seen an issue before (on a Sony Ericsson device) where the app appeared to hang opening a network connection, which turned out to be because it was waiting for user permission, but the dialogue was hidden behind the application and the user could not see or interact with it, so could not give the permission the app was waiting for.

    I now realize that in your case it should not be asking for permission, right?

    Can only echo traud's suggestion to use on-device debug and find out exactly which API call is hanging.
    I have already answered what you asking again and again, I have the code I posted here, I can give u a sample app (signed) if you want to try it by your own as I said it only creates issue only if app is signed, and the line of code that creates issue or where app hangs is

    clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY, lists[i]);
    for the very first time, thats it.

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

    Re: PIM Issue & Sim Contacts read problem

    OK, sorry, that wasn't clear to me from your other posts that you knew it was hanging on a specific line.

    If you want to log a bug, you can do so here. This does not appear to be a known issue.

    I can suggest: try changing from PIM.READ_ONLY to PIM_READ_WRITE.

    Are you sure it is hanging, or just that the next line of code is never reached? Try catching Throwable instead of Exception. Usually, I wouldn't recommend catching either, but in this case you might be missing an Error getting thrown and telling you something useful.

  12. #12
    Registered User
    Join Date
    Nov 2012
    Location
    Lahore, Pakista
    Posts
    58

    Re: PIM Issue & Sim Contacts read problem

    Quote Originally Posted by grahamhughes View Post
    OK, sorry, that wasn't clear to me from your other posts that you knew it was hanging on a specific line.

    If you want to log a bug, you can do so here. This does not appear to be a known issue.

    I can suggest: try changing from PIM.READ_ONLY to PIM_READ_WRITE.

    Are you sure it is hanging, or just that the next line of code is never reached? Try catching Throwable instead of Exception. Usually, I wouldn't recommend catching either, but in this case you might be missing an Error getting thrown and telling you something useful.
    I did try using both PIM.Read_only and PIM.Red_write but same result.
    Here comes a little different thing from your question and I guess it may be that I am understanding the error wrong way, when I tried to use this whole code as a single method what happened was that whole screen hanged and I was unable to move or do anything exception force close (this happens for the firs time start when line of code is what I mentioned before). Secondly I tried same code putting it in Thread then what happened was application didn't hang due to separate thread calling but when I called that method it run and stopped there on the same line, I tried it again being in the same session what happened was that it started from beginning and stopped at the same place, now this is a little different behavior that could be helpful for your to give me some idea what that could be.
    Talking about the throwable, I didn't try that method, I am gonna give it a try till then hopefully you find something useful from this. I will be back, thanks for the info.

Similar Threads

  1. problem in read contacts
    By sh3at in forum Symbian
    Replies: 1
    Last Post: 2011-07-14, 08:34
  2. How to read contacts
    By sreehari434 in forum Mobile Java General
    Replies: 8
    Last Post: 2009-11-28, 05:51
  3. AT command issue to read contacts
    By mukeshkb4u in forum General Messaging
    Replies: 0
    Last Post: 2009-03-30, 08:10
  4. Replies: 13
    Last Post: 2008-07-23, 17:06
  5. read contacts in S40
    By oscarm in forum Mobile Java General
    Replies: 6
    Last Post: 2008-02-27, 17:13

Posting Permissions

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