Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Ykimss
Posts: 4
Registered: ‎04-08-2009
My Device: Not Specified

ContactGroup problem

I am developing BB app using BlackBerryContactGroup.

I added  contact to ContactGroup.
I added the same contact ( using the different attribute) to ContactGroup.

 

For example,

 

TestCompany
Work: 416-123-4567
Home: 416-234-4567
Mobile: 416-345-4567


TestGroup
TestCompany(Work)
TestCompany(Home)
TestCompany(Mobile)


And then, if I want to get the each phone nos from 'TestGroup',
ContactGroup returns the whole information for each Contact.

 

That means ContactGroup returned three 'TestCompany' information,
not 'TestCompany(work)', 'TestCompany(home)' and 'TestCompany(mobile)' information.

 

Anyone know about this issue?

Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: ContactGroup problem

[ Edited ]

I may have misunderstood your question so bare with  me but a ContactGroup stores Contacts. If you want, you can have 3 different phone numbers for one Contact and not need for it to be in a ContactGroup.

 

Since you've added:

 

TestCompany(Work)
TestCompany(Home)
TestCompany(Mobile)

 

To:

 

TestGroup

 

you have 3 contacts all with their own phone numbers in TestGroup. So each of them has Home, Work and Mobile phone numbers as well as e-mail, fax, address, etc.

 

Did I understand correctly?

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
New Developer
Ykimss
Posts: 4
Registered: ‎04-08-2009
My Device: Not Specified

Re: ContactGroup problem

This is my source code.

 

 

 

           if(context instanceof BlackBerryContactGroup){
                System.out.println("Context is group");
                BlackBerryContactGroup contactGroup = (BlackBerryContactGroup)context;
                Vector vcContacts = new Vector();
                for(int i=0;i<contactGroup.numContacts();i++){           
                    vcContacts.addElement(contactGroup.getContact(i));
                }
                doGroupCallAction(vcContacts);
               


....

 

 

void doGroupCallAction(Vector blackBerryContacts){
 for(int i=0;i<blackBerryContacts.size();i++){
  BlackBerryContact item =
                    (BlackBerryContact)blackBerryContacts.elementAt(i);
  System.out.println(item.getString(BlackBerryContact.TEL,0));
 }
 
 }


==> Program always print WORK number only.

Developer
JCarty
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: ContactGroup problem

[ Edited ]

 

item.getString(BlackBerryContact.TEL,0);

 

0 in this line of code is the index of the first number that you can retrieve. If you were to go do the following:

 

 

int phoneNoCnt = contact.countValues(BlackBerryContact.TEL);

for( int i = 0; i < phoneNoCount; ++i ) {

if( contact.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_HOME ) {
System.out.println("Home number: " + contact.getString(BlackBerryContact.TEL, i));
}
}

 

That should give you the home phone number.

 

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
New Developer
Ykimss
Posts: 4
Registered: ‎04-08-2009
My Device: Not Specified

Re: ContactGroup problem

Thanks for your response.

I want to know what kind of phone no (Work? Home? Mobile?) in the group.

 

for example)

I made only one contact (CompanyA) in my addressbook.

One contact has three phone nos. (Work,Home,Mobile)


CompanyA

Work : 416-123-4567
Home : 416-234-4567
Mobile : 416-345-4567


I made one contact group with one contact(CompanyA).


Addressbook screen is like this.

TestGroup

CompanyA(Work)
CompanyA(Home)
CompanyA(Mobile)

===> TestGroup has 3 phone no. 416-123-4567,416-234-4567,416-345-4567
===> Even  though all 3 contact were same, TestGroup returned 3 conatct info.


But, in the program, I can get the contact info from contactgroup.
I don't know what kind of phone no was saved.


Is there any information something like 'addressCardSyncFieldId'?

In the program, I only know contact info.

 

In the program, if user selects item in the addressbook,

program sends sms message to the selected phone no.

if selected item is BlackberryContact
and this conatct has more than one phone no(Work,Home,Mobile),

and then program asks the user which phone number user want to send.


Another Case:


If selected item is BlackBerryContactGroup,

and then program send sms message to all phone number of the contactgroup.

I can retrieve the contact information from the contactgroup,

but if this contact has more than one phone number,

I can't get what kind of phone number was saved in the contactgroup.


When I saved contact to the contactgroup,

(this contact has more than one phone number)

I can specified one attribute phone number only.

But, when I retrieve the contact from contactgroup,

I can't get the infomation of specified attribute. (Work?Home?Mobile?)

 

In the internal class (GroupAddressCardMember), this class has the specified sync field.

(addressCardSyndFieldId)


It is hard to explain my situation.


Sorry for my bad English.

Thanks.