BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-09-2011, 04:44 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2011
Model: 9550
PIN: N/A
Carrier: development
Posts: 18
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default Check or remove existing Listener

Please Login to Remove!

Hi!
I have a problem. When my application starts, I want to check is there already my MessageListener setted, if not i will set it.
If i don't check this and set my MessageListener will have several listeners after several launches.
For example: open my application - set MsgListener - close app - Listener is still running (in some kind system thread as i understand) - open my app - set another Listener - there two listeners in deferent threads is running.
Please, tell how i can solve this problem?
Offline  
Old 02-09-2011, 10:01 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: Check or remove existing Listener

You need to make sure that you remove these listeners when your application closes.
Offline  
Old 02-10-2011, 06:20 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2011
Model: 9550
PIN: N/A
Carrier: development
Posts: 18
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: Check or remove existing Listener

Quote:
Originally Posted by Dougsg38p View Post
You need to make sure that you remove these listeners when your application closes.
So, this is the question. How to remove Listeners and how to check is they are setted?
Offline  
Old 02-10-2011, 08:22 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: Check or remove existing Listener

You added the listener, right? You retained a reference to the listener, and when your application closes, you removed it.

Am I missing something?
Offline  
Old 02-10-2011, 10:14 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2011
Model: 9550
PIN: N/A
Carrier: development
Posts: 18
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: Check or remove existing Listener

Quote:
Originally Posted by Dougsg38p View Post
You added the listener, right? You retained a reference to the listener, and when your application closes, you removed it.

Am I missing something?
Let me explain. When i close my app i don't need to remove listeners - it's good for me when it works in some kind system process or something like than. So when i start my application again i don't have reference on my listeneres. All i can do - it's save reference into RuntimeStore for example, but is there a way to check or remove immediately existing Listeners.
Or maybe i can override OnClose method and just hide my application?
Offline  
Old 02-10-2011, 10:53 AM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: Check or remove existing Listener

If you don't have references to your listeners, how would you know the ones you are removing are yours?

Dougsg38p is right. You need to keep track of what you do and either clean up or not over commit resources (like listeners).
__________________
My other Blackberry is a PlayBook.
Offline  
Old 02-10-2011, 11:21 AM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2011
Model: 9550
PIN: N/A
Carrier: development
Posts: 18
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: Check or remove existing Listener

Quote:
Originally Posted by hrbuckley View Post
If you don't have references to your listeners, how would you know the ones you are removing are yours?

Dougsg38p is right. You need to keep track of what you do and either clean up or not over commit resources (like listeners).
Thanks for reply.
One more question, how can i turn aside my application on button click, like i'm clicking on "red button"?
Offline  
Old 02-10-2011, 12:14 PM   #8 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: Check or remove existing Listener

Is net.rim.device.api.system.Application.requestBackg round() what you're looking for?
__________________
My other Blackberry is a PlayBook.
Offline  
Old 02-10-2011, 08:01 PM   #9 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: Check or remove existing Listener

Or possibly UiApplication.deactivate()

This is called when your app is forced to background.

Also look at UiApplication.activate()
Offline  
Old 02-11-2011, 04:25 AM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2011
Model: 9550
PIN: N/A
Carrier: development
Posts: 18
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: Check or remove existing Listener

Thanks everyone. Seems, i make it works as needed.
Offline  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Check or remove existing Listener
Thread Thread Starter Forum Replies Last Post
Cant Remove Basque Language jsincere General BlackBerry Discussion 12 10-01-2009 04:54 PM
Unite! Help Guide Sith_Apprentice BlackBerry Unite 17 12-25-2008 02:08 PM
New Blackberry Server wants to reactivate users after power outage! Urlryn BES Admin Corner 19 12-27-2007 03:55 PM
Application push not working: "Configuration check returned error 11" eZainny BES Admin Corner 1 04-30-2007 01:51 AM





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