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

Posts: 67
Registered: ‎01-13-2009
My Device: Not Specified

Determining Initial Status from a Listener

Hi all.


I have a generic question about listeners.  Amongst others my program needs to Implement a WIFI Connection Listener and a Radio Coverage Listener.  Once the command to begin the program has been given, I implement the required listeners and then begin some prerequisite checks (all to do with the results of listeners).  Given the nature of the program, I don't want the program to continue if their is no network coverage.  However the listener only detects changes.  I have tried setting up an initial decision structure which will verify that the basic requirements exist which has become extremely inefficient and complicated. 


It seems to me that it would be redundant to set up a listener to listen for a change in network coverage, yet still (externally to the listener) have to perform a check along the same lines as isCoverageSuffient() before proceeding with the program.


I would like to find out if their is a way when initializing the listener to get the current state of most cases that have been set up, ie Direct coverage, no coverage, mds, WLAN state, etc.  To do this I have tried setting up some private global variables and return methods to return a value based on which case statement was met / could have been active, but these case statements only get activated when a change occurs, never before.  So I think if I could find a way to get the program to think there was a change almost immediately after it was created to either start the appropriate action or set a corresponding value, that would be the most efficient. 


I am also open to any common conventions for determining the initial conditions from a listener if my above expectation is unrealistic. 


Currently all I am using are Listeners that I can implement, I haven't written my own listeners from Scratch. 


Thanks a lot.

BlackBerry Development Advisor
Posts: 15,813
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Determining Initial Status from a Listener

Listener methods are only fired when something changes.  You'll need to use other classes to determine the current state of coverage.  You can then update this based on listener methods that are fired.  Please see the following.



How To - Determine when to route data 
Article Number: DB-00485


Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.