BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-25-2008, 02:50 PM   #1
BB_developer
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 15
Default HELP!!! Cannot read address book - index language out of bounds exception.

Please Login to Remove!

Hi,

I cannot seem to read all contacts in BB address book. I followed the sample code below, it works on some devices, but not other.

It will return " Uncaught exception java index language out of bounds exception.".

Livelink - Redirection

Please help!!
Offline  
Old 05-25-2008, 02:54 PM   #2
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

Did you figure out this problem? I'm having the exact same problem and was forced to use the method of opening the contacts list from my app then access the selected contact. this seems to work but the list show "use once" option that I don't want displayed.

BlackBerryContactList list = BlackBerryContactList)PIM.getInstance().openPIMLis t(PIM.CONTACT_LIST, PIM.READ_ONLY);

Contact contact = list.choose(null, BlackBerryContactList.AddressTypes.EMAIL, false);
Offline  
Old 05-25-2008, 03:19 PM   #3
BB_developer
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 15
Default

Hi,

What type of device did you see the same problem? Have you debugged and see where it errors out?
Offline  
Old 05-25-2008, 03:31 PM   #4
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

I tried it on 8100 T-mobile and 8800 Cingular. both gave the same error when scrolling after about 30-35 contacts.

So I decided to open the contacts list from my app and access the selected contact info that way. every other field is working now except for address. I can't figure out how to grab the "BlackBerryContact.ATTR_WORK" or " BlackBerryContact.ATTR_HOME".
Offline  
Old 05-25-2008, 03:34 PM   #5
BB_developer
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 15
Default

I have an idea, when you say it stops at 30-35, I wonder it might be that one of the fields is generating exception. Put a catch and see which one is giving you the exception, then examine its fields and find out what makes it special.
Offline  
Old 05-25-2008, 03:38 PM   #6
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

I thought about this and tried to do such. even tried to debug and step through the code but I could never reach the scrolling part. do you know where to put the break to catch the error during scrolling?
Offline  
Old 05-25-2008, 03:41 PM   #7
BB_developer
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 15
Default

If you are using the sample code list at BB site:
Livelink - Redirection

Then try putting the catch at drawListRow
Offline  
Old 05-25-2008, 03:44 PM   #8
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

yep was using that exact sample. I'll try it now will have to dig out the last version of that code.
Offline  
Old 05-25-2008, 03:56 PM   #9
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

tried to step through it but didn't get any errors. while scrolling through list on device if i try to go past the 30-35 contact i get "Uncaught exception unpaired graphics.push(mrv_v) in class net.rim.device.api.container.verticalfieldmanager" I tried to report this on the BB developer forum but didn't get any answers.

that where i left it and started using the other method.
Offline  
Old 05-25-2008, 04:04 PM   #10
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

So I'm using this now and it seems to work.
the problem is getting the HOME or WORK address. it seems to never be true for either.
Do you know what the problem is?

BlackBerryContactList list = (BlackBerryContactList)PIM.getInstance().openPIMLi st(PIM.CONTACT_LIST, PIM.READ_ONLY);

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

if (contact != null)
{
for (atrCount = 0; atrCount < contact.countValues(BlackBerryContact.ADDR); ++atrCount)
{
address = contact.getStringArray(BlackBerryContact.ADDR, atrCount);
if (contact.getAttributes(BlackBerryContact.ADDR, atrCount) == BlackBerryContact.ATTR_HOME)
{ do some stuff }
else if (contact.getAttributes(BlackBerryContact.ADDR, atrCount) == BlackBerryContact.ATTR_WORK)
{ do some stuff }
}
}
Offline  
Old 05-25-2008, 04:40 PM   #11
BB_developer
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8800
PIN: N/A
Carrier: t-mobile
Posts: 15
Default

Hi,

What is the main difference between this version vs the sample that prevent it from crashing?

I think the probelm might be the loop condition:
for (atrCount = 0; atrCount < contact.countValues(BlackBerryContact.ADDR); ++atrCount)

If you check the sample, you will need to loop through all the fields until it finds address field, then you can drill in for home address etc.
Offline  
Old 05-25-2008, 04:55 PM   #12
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

this method opens a contact list in my application. I can then scroll the entire list and select a Contact contact. then use the contact reference to get each field.

"for (atrCount = 0; atrCount < contact.countValues(BlackBerryContact.ADDR); ++atrCount)" should return number of record in BlackBerryContact.ADDR field. return can be between 0 - 2 for ATTR_NONE, ATTR_HOME, ATTR_WORK.

"if (contact.getAttributes(BlackBerryContact.ADDR, atrCount) == BlackBerryContact.ATTR_HOME)" should tell me if the index is pointing to either ATTR_HOME or ATTR_WORK then I can retrieve the address details for each.

but for some reason when i run it the "If and Elseif" never runs and I get no address information.

but I know address is there because if i comment out the If and elseif I get all the data for the ATTR_HOME and nothing for ATTR_WORK.

I'm stomped on this.
Offline  
Old 05-25-2008, 05:03 PM   #13
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

oh have an idea. I could fix the index in this statement:

//Extract the address fields in a string array.
address = contact.getStringArray(BlackBerryContact.ADDR, atrCount);

make it

address = contact.getStringArray(BlackBerryContact.ADDR, 0); //ATTR_HOME
and
address = contact.getStringArray(BlackBerryContact.ADDR, 1); //ATTR_WORK

and catch any error if either does not exist. will try it and see if it blows.

==========================
yeah it blows on the second line where index = 1 with an index out of bounds exception
index = 0 returns all the ATTR_HOME address fields.

strange because retrieving all the different phone numbers are retrieved in similar method.


found this in API help:

Field Values Per Field Supported Attributes
Contact.NAME 1 PIMItem.ATTR_NONE
Contact.TITLE 1 PIMItem.ATTR_NONE
Contact.ORG 1 Contact.ATTR_WORK, Contact.ATTR_HOME
Contact.ADDR 1 PIMItem.ATTR_NONE
Contact.NOTE 1 PIMItem.ATTR_NONE
Contact.TEL 5 Contact.ATTR_WORK, Contact.ATTR_HOME, Contact.ATTR_MOBILE, Contact.ATTR_PAGER, Contact.ATTR_FAX, Contact.ATTR_OTHER
Contact.EMAIL 3 PIMItem.ATTR_NONE
Contact.PHOTO 1 PIMItem.ATTR_NONE
Contact.NOTES 1 PIMItem.ATTR_NONE
Contact.UID 1 PIMItem.ATTR_NONE
BlackBerryContact.USER1 1 PIMItem.ATTR_NONE
BlackBerryContact.USER2 1 PIMItem.ATTR_NONE
BlackBerryContact.USER3 1 PIMItem.ATTR_NONE
BlackBerryContact.USER4 1 PIMItem.ATTR_NONE
BlackBerryContact.PIN 1 PIMItem.ATTR_NONE
BlackBerryContact.DCID 1 PIMItem.ATTR_NONE

looks like I was wrong. there is only (1) value for Contact.ADDR. It will never return both address types. the method I'm using is from BB developer site.

Last edited by mauiboy; 05-25-2008 at 05:24 PM..
Offline  
Old 05-25-2008, 05:31 PM   #14
mauiboy
Thumbs Must Hurt
 
Join Date: May 2005
Model: 8100
Carrier: T-Mobile
Posts: 93
Default

these two lines seems wrong:

Contact.ORG 1 Contact.ATTR_WORK, Contact.ATTR_HOME
Contact.ADDR 1 PIMItem.ATTR_NONE

There are never more than 1 Contact.ORG in the address book. but there are both Home and Work address fields in address book. can someone explain this?
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


IBM Genuine OEM Printer Filler Wide Credit Card Holder 10N1259 picture

IBM Genuine OEM Printer Filler Wide Credit Card Holder 10N1259

$24.79



IBM Correctable Ribbon Cassette Black 1299300 NOS Original OEM picture

IBM Correctable Ribbon Cassette Black 1299300 NOS Original OEM

$2.99



IBM CASH DRAWER KEY'S #9960 SET OF 2 KEYS. AFTERMARKET KEY'S SAME AS OEM 33G3360 picture

IBM CASH DRAWER KEY'S #9960 SET OF 2 KEYS. AFTERMARKET KEY'S SAME AS OEM 33G3360

$18.00



IBM OEM PN/7032253 or PN/7032252 Projection Lamp - New in Box Old Stock EPZ picture

IBM OEM PN/7032253 or PN/7032252 Projection Lamp - New in Box Old Stock EPZ

$8.46



OEM  IBM Type 5441 WheelWriter 3 1356658 1362400-02 Main Boards Tested Working picture

OEM IBM Type 5441 WheelWriter 3 1356658 1362400-02 Main Boards Tested Working

$34.99



IBM WHEELWRITER TYPEWRITER TRANSPORT MOTOR Series II - OEM wheelwriter parts picture

IBM WHEELWRITER TYPEWRITER TRANSPORT MOTOR Series II - OEM wheelwriter parts

$28.00







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