04-13-2010 10:26 AM
Hello Friends,
I am trying to download contacts from server and then save these contacts in phonebook with the following code. Following code is for saving the contacts into phonebook. This code works perfect if I am saving 2 or three contacts. But when I try to download 10 or more contacts, I am getting error. The downloading of more than 10 contacts is working but it is not saving the contacts and giving following error. If I comment the following code in my application, then it works fine. (I mean downloading is done but contacts are not saved)
The error is "Uncaught exception Application net_rim_bb_phone_app(66) is not responding ; process terminated"
If I use follwoing code in Timer
then I am getting following error
" Uncaught exception Application net_rim_bb_phone_app(206) is not responding ; process terminated"
What could be the problem??
public void saveContacts()
{
if(timer!=null)
{
timer.cancel();
timer=null;
}
String conStr = new String(ContactRetrieve);
try
{
BlackBerryContactList contactList = null;
contactList = (BlackBerryContactList) PIM.getInstance()
.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
while (conStr.length() != 0) {
{
String lName="MyName",
fName="MyLastName",
tel ="1212989898",
email="myid@mymail.com",
mobile="98989898";
try {
String[] arrayField = new String[5];
arrayField[BlackBerryContact.NAME_FAMILY] = lName;// LastName
arrayField[BlackBerryContact.NAME_GIVEN] = fName;// FirstName
arrayField[BlackBerryContact.NAME_PREFIX] = "";// Title
if (contactList
.isSupportedField(BlackBerryContact.NAME)) {
contact.addStringArray(BlackBerryContact.NAME,
PIMItem.ATTR_NONE, arrayField);// see above
}
if (contactList
.isSupportedField(BlackBerryContact.EMAIL)) {
contact.addString(BlackBerryContact.EMAIL,
BlackBerryContact.ATTR_NONE, email);
}
if (contactList.isSupportedAttribute(
BlackBerryContact.TEL,
BlackBerryContact.ATTR_HOME)) {
contact.addString(BlackBerryContact.TEL,
BlackBerryContact.ATTR_WORK, tel);
}
if ((contactList).isSupportedAttribute(
BlackBerryContact.TEL,
BlackBerryContact.ATTR_MOBILE)) {
contact.addString(BlackBerryContact.TEL,
BlackBerryContact.ATTR_MOBILE, mobile);
}
contact.commit();
Thread.currentThread().sleep(600);
Thread.yield();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
catch(Exception e)
{
}
Dialog.inform("Download Successful..");
}
Thank you
04-13-2010 10:28 AM
i would guess you do this in a phonelistener. code in a phonelistener is executed in the context of the phone application.
you are also using thread.sleep without having a dedicated thread, this means you block the whole phone application for this time.
1. move processing to your app, using global events, runtimestore or callbacks+invokelater.
2. use a dedicated thread
04-14-2010 01:28 AM
Hello Simon_hain,
Thank you for your reply,
I implemented dedicated thraed as per your suggestion. But then also I am getting same type of problem. ![]()
I am not able to get what the problem is??
Thank you
04-14-2010 03:48 AM
move the processing into your own application as described in
http://supportforums.blackberry.com/t5/Java-Develo