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
Posts: 5
Registered: ‎01-04-2009
My Device: Not Specified

Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

I'm using ApplicationMenuItem to add a menuitem to the contact app. Everything seems to work and contacts can be propertly selected, etc.

 

//public Object run(Object context) {

//... 

//  context is fine for contacts

//  context is null for groups - why?

//}

 

However, I need to select groups as well. When groups are selected, the context argument is null. Is this intentional? Is there any way around it? Is there a way to get the currently selected contact/group from the contact app?

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

This is a known issue, reported to RIM. My guess is that it is an oversight on the part of the RIM implementors.
New Developer
Posts: 5
Registered: ‎01-04-2009
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

Is there any way to ask a user for a contact and/or group from the address book, which actually provides a contact and/or group (provides both)?

 

I'm lost as how to proceed:

 

* It would be nice to be able to do this with an app menu item in the address book, but I would be happy if there is any way to do it; our users need to select contacts and groups

 

* I've tried using "choose()", but I was also unsuccessful when selecting a group there; I know other apps can do this, such as SMS, which take contacts and groups

 

* I'm tempted to enumerate all the contacts and groups in our own selection list if all else fails, but I'd like to avoid this for obvious reasons if possible

 

Any ideas? I'm only developing for the BlackBerry, so this doesn't have to run cross-platform. Presently only the Curve 8810/8820 needs to work, but I'm hoping that we could support more BlackBerry models in the near future.

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

[ Edited ]

If you open the contact, the menu injection passes the context item correctly.

 

Maybe you can intercept the null context and instruct the user to open the contact?

 

Failing that, I'm guessing that you will have to build your own contact list from the PIMList, as you suggested. You can make this a one-shot deal and place a listener on the Contacts list so that you pickup any adds/deletes/etc.

 

 

Message Edited by RexDoug on 01-05-2009 09:46 AM
New Developer
Posts: 5
Registered: ‎01-04-2009
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

You mean the contact within the group?
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

[ Edited ]

Yes, but I think you are trying to pick up an entire group through the menu injection, right?

 

Message Edited by RexDoug on 01-05-2009 09:47 AM
New Developer
Posts: 5
Registered: ‎01-04-2009
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

I am. I'm trying to allow selection of groups, to allow the users to submit multiple contacts instead of one at a time.

 

Any thoughts on how I could accomplish this?

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

Build and maintain your own contact list, I guess. As I said above, you can do a one-time import on initial startup, then place a listener on the Contacts list to pick up any changes.

 

I don't know of any better way.

 

If performance is not a critical issue, you can try to build your own list on-demand. When the contacts list is not to big, this might be fine.

 

 

 

New Developer
Posts: 5
Registered: ‎01-04-2009
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

Can you see any potential problems doing this, such as things getting out of sync?
Highlighted
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Contact groups result in a null context (Using ApplicationMenuItem to add contact app menuitem)

I would try the "on demand" first. If your ultimate goal is to (for example) send the same SMS to everyone in a group, the actual retrieval of the data list from Contacts (IMHO) is not going to significantly impact the overal time that this is going to take. The actual sending of the message will be much slower.

 

You have to code this extraction anyway, so I would start there. If the performace is a real issue, than you can fall back to the one-time import and install the listener interface and service routine.

 

As a fallback, you can always have a menu item called "re-sync with contacts", which would re-import from the current list.