BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-04-2010, 07:56 AM   #1 (permalink)
New Member
 
Join Date: Feb 2010
Model: 9500
PIN: N/A
Carrier: NA
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Smile how can existing contact list be imported in my own application.

Please Login to Remove!

Hi,
I want to import the existing contact list to my application.
Can anyone help me in this with sample code.

Thanks in advance.
Offline  
Old 03-04-2010, 08:40 AM   #2 (permalink)
New Member
 
Join Date: Feb 2010
Model: 9500
PIN: N/A
Carrier: NA
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

i am doing this in the following way:

try{
BlackBerryContactList list = (BlackBerryContactList)PIM.getInstance(). openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
BlackBerryContact contact = (BlackBerryContact)list.choose (null, BlackBerryContactList.AddressTypes.EMAIL, false);
System.out.println("conatact"+contact);
int numValues = 0;
numValues = contact.countValues(BlackBerryContact.TEL);
System.out.println(numValues);
String contactnames = new String();
for (int i = 0; i < numValues; i++)
{
if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_WORK)
{
contactnames = contact.getString(BlackBerryContact.TEL, i);
System.out.println("contactnames"+contactnames);
}
}
}
catch(Exception pe)
{
System.out.println(pe.getMessage());
}


But when I run my code I get Exception which says:" pushModalScreen called by a non-event thread "

plz tell me where i am wrong.

thanks!
Offline  
Old 03-04-2010, 08:58 AM   #3 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

The exception means that you are trying to display a screen or dialog from a thread other than the UI Event thread. However, I don't see any screen push here.

Where is this exception being thrown?
Offline  
Old 03-04-2010, 09:48 AM   #4 (permalink)
New Member
 
Join Date: Feb 2010
Model: 9500
PIN: N/A
Carrier: NA
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Dougsg38p,

I have one class where I am displaying the screen:

class WM extends UiApplication{
public static void main(String [] args)
{
WM wm= new WM();
wm.enterEventDispatcher();

}
public WM() {
pushScreen(new WMtLogin());
}
}


and in WMLogin we have:

class WMLogin extends MainScreen{
public WMLogin() {
super();
try{
BlackBerryContactList list = (BlackBerryContactList)PIM.getInstance(). openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
BlackBerryContact contact = (BlackBerryContact)list.choose (null, BlackBerryContactList.AddressTypes.EMAIL, false);
System.out.println("contact"+contact);
int numValues = 0;
numValues = contact.countValues(BlackBerryContact.TEL);
System.out.println(numValues);
String contactnames = new String();
for (int i = 0; i < numValues; i++)
{
if (contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_WORK)
{
contactnames = contact.getString(BlackBerryContact.TEL, i);
System.out.println("contactnames"+contactnames);
}
}
}
catch(Exception pe)
{
System.out.println(pe.getMessage());
pe.printStackTrace();
}
}


}


EXception occurs at the line:

BlackBerryContact contact = (BlackBerryContact)list.choose (null, BlackBerryContactList.AddressTypes.EMAIL, false);


Plz advice on this.

Thanks in advance!
Offline  
Old 03-04-2010, 03:35 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

OK, so the "choose" method actually displays a dialog. This is where your problem lies.

You are calling this method in you WMLogin constructor, and of course you have not yet entered the event dispatcher at this point.
Offline  
Old 03-05-2010, 06:29 AM   #6 (permalink)
New Member
 
Join Date: Feb 2010
Model: 9500
PIN: N/A
Carrier: NA
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Dougsg38p!

But can you plz tell me the solution to the problem.

How can I resolve the issue.
Offline  
Old 03-05-2010, 09:10 AM   #7 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Well, you cannot do anyting that interacts with the UI unless you have entered the dispatcher. You need to restructure this code.

Frankly, I don't understand what you are trying to do, and I cannot write your code for you.

this choose() method is used to look up a single contact, with operator intervention. This doesn't seem to be the same thing you *say* you are trying to do.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.