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
Contributor
Posts: 12
Registered: ‎06-16-2011
My Device: 9000
My Carrier: Vodafone
Accepted Solution

How to Call BlackBerryContactList.choose() from background applicaiton

I am facing a problem while calling BlackBerryContactList.choose() from background applicaiton (Applicaiton) nothing is happening.

 

Bellow is code

 

BlackBerryContactList list = (BlackBerryContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
PIMItem choose = list.choose();

 

While calling it from a UI applicaiton is working fine but same is not working while calling from Background applicaiton.

 

Please help me...

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Call BlackBerryContactList.choose() from background application

Doesn't this popup a list for the user to choose from?  If so, how do you expect that to work from a background application?

Contributor
Posts: 12
Registered: ‎06-16-2011
My Device: 9000
My Carrier: Vodafone

Re: How to Call BlackBerryContactList.choose() from background application

Actually i am having a background applicaiton which will prompt the user to add to MDN to adress book if that is not in address book in that case i want to call choose to tack a selection via user.

 

This complete operation is managed by Background applicaiton.

Invoke.invokeApplication(Invoke.APP_TYPE_ADDRESSBOOK, new AddressBookArguments(AddressBookArguments.ARG_NEW, con)); is working fine from background applicaiton only choose is having the problem.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Call BlackBerryContactList.choose() from background application

The invocation will be fine from a background application because it starts a completely separate application that is not related at all to your current application.  But in the choose you want to pop up a screen for the user and keep control of this processing.  I don't think you are going to be able to do this from a background application that has no screen. 

 

I am not actually clear on what you are trying to do.  You are prompting the user to add MDN (what is MDN?) to the address book - presumably that is how you are using the invoke.  But be aware that your application does not stop while this happening.  In other words if you test that a user is not present, use invoke to get the user to add it, and then immediately after the invoke, check if the user is there, it will NOT be there, regardless of what the user does on the Address book screen that you have invoked.  Does this make sense? 

 

I don't get the second part.  If it is not in there, then the user has to choose another what?  I don't understand "tack a selection via user"

Contributor
Posts: 12
Registered: ‎06-16-2011
My Device: 9000
My Carrier: Vodafone

Re: How to Call BlackBerryContactList.choose() from background application

MDN is actually a mobile no.

My Applicaiton flow is when user gets a call then at call end my Background applicaiton will check in addressbook and if that mobile no is not there then will ask user do you want to add this contact to your addressbook with 2 options

As as new contact or Add to existing contact. Here my first case if fine because in that i need to user directoly invoke but in 2nd case i need to first tack the user contact selection. For that i need to call choose and that is not working.

 

Please suggest a way to achive the same.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Call BlackBerryContactList.choose() from background application

Let us start at the beginning.  How are you doing this?

 

"will ask user do you want to add this contact to your addressbook with 2 options"

Contributor
Posts: 12
Registered: ‎06-16-2011
My Device: 9000
My Carrier: Vodafone

Re: How to Call BlackBerryContactList.choose() from background application

That dialog i am colling from UI.getUIEngine.pushModleScreen(dialog, ..., Globle_Queue);

 

Then once user selects option Add to a existing contact then i want to call choose method.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Call BlackBerryContactList.choose() from background application

This Dialog runs separately from your Application.  It is not actually part of your Application.  It is a Global screen.  This will work fine. 

 

However to use the choose Dialog, I think you will have to get control back into your application and, as you have found, I think you will need to bring your application to the foreground in order to make sure that he choose Dialog is shown.  This means you are going to have to run a UiApplication, not an Application. 

 

To make sure this Application can not bought to the foreground accidentally, you can set acceptsForeground() to false. 

 

But when you want to use the choose Dialog, you will need to have this method return true, and then bring your Application to the foreground.  When you get the response to the choose, you can set it to false, and take your application to the background again. 

 

I suggest while you are developing this you just create a standard UiApplication, and get it working like that.  Then try simulating a background application by adjusting acceptsForeground() at appropriate times.

 

Since your application will in fact be a UiApplication, I suggest that you do have a screen associated with it too.  A simple splash screen will do. 

 

Hope this helps. 

 

PS>  There is a small chance that you can requestForeground on your Application when you invoke the choose method and it will display.  Try it.  But I won't be surprised if it fails.