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
Highlighted
Developer
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

phonelistener revisited

[ Edited ]

Trying to figure out where to place code for deregister a phone listener.

As the story goes. "Yes teacher, I am still confused, but at a higher level"

Example says: -----------

 

...
MyPhoneDeregister phone_handler;
...

// call this method on exit to deregister the phone listener
private callOnExit()
{
Phone.removePhoneListener(phone_handler);
}
}

---------

 

Is this code to be placed in the phone listener itself? If so, how do I trigger it? The only code that activates the phone listener is a phone call. Right? If the above code is not to placed in the phone listener what do I put in for "phone_handler"?

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: phonelistener revisited

As you mention, it can be called from within the PhoneListener (one of the listener methods).

 

If you need to call it from within your application (i.e. a GUI portion) you could store a copy of the PhoneListener in the RuntimeStore when it is first created.  That way, you can open the same PhoneListener instance stored as an object in the RuntimeStore at a later time and deregister it.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: phonelistener revisited

Thanks,

 

I do have to stop it from the controlling application. Is the method of  creating and storing the listener in RuntimeStore

described somewhere. I am having problem implementing a Runtime store so some kind of sample would be helpful

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: phonelistener revisited

"I am having problem implementing a Runtime store so some kind of sample would be helpful"

 

So where have you looked for a sample?

 

I've found examples of its use in the Developer Guide, samples supplied and KB, including this very useful example.

 

How to - Create a singleton using the RuntimeStore
Article Number: DB-00686
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/832062/How_to_...