BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-14-2005, 10:16 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2005
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Best Way to Implement a Debug Screen

Please Login to Remove!

Hello,
I have developed a few apps that work together. I have also created an OptionsProvider, under which I want the option to display a "debug" screen. This debug screen should contain messages sent by any of the other applications in my suite.
My first attempt at this did work (using a RunTime object (string) which I appended to every time). The problem is that when I run it the first time everything is good, but if I exit the debug screen then I can never access it again because I get an Exception.

Is there a bettery way to create such a debug screen?
Offline  
Old 04-15-2005, 07:52 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2004
Location: Metro NYC
Posts: 175
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I create debug screens that require a certain series of keystrokes to display. Similar to the display of RIM's log screen (ALT-L-G-L-G).

In my KeyListener, I check for ALT plus the keys and display my screen.
__________________
-- Aric Rosenbaum
BlackBerry consulting, BlackBerry development
www.arconsultinginc.com
BlackBerry consulting and development (RIM SI Partner)
Offline  
Old 04-15-2005, 11:22 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2005
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have toyed with that idea, but it isn't really required for my application. In any event, the problem wasn't so much "how to access the screen", but rather, how to pass data from other applications.

Right now I am using a RuntimeStore object (a string) which I append to. The problem is that when I show the screen it does not get updated in realtime.

eg:
Other applications write to the debug screen by calling:
Code:
DebugScreen.DebugMessage("This is my message");
The OptionsProvider creates the screen when required, and the constructor creates a RichTextField.

Code:
class DebugScreen /*...*/{
   private static RichTextField _output;
   /* ... */
   public DebugScreen(){
      /* ... */
      String strCurrOutput = /* Get from runtime store */
      _output = new RichTextField("Started...\n" + strCurrOutput);
   }

   /* ... */
   public void DebugMessage(String msg){
      /* add msg to runtimestore object */
      if(_output != null){
        _output.setText( textfromruntimestore );
      }
   }
}
When I first open the debug screen, I get all debug messages that were present in the runtime store (no problem there). The problem is that while the window is open, it never gets updated!

Last edited by smheoc : 04-15-2005 at 11:25 AM.
Offline  
Old 04-15-2005, 11:52 AM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2005
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have a working solution now, however I welcome recommendations...

I have created two RuntimeStore objects, one String to contain all the messages, and one RichTextField to indicate if the window is visible.

1) In the constructor for the display, I create the RTF object and populate it with the String contents.

2) In the onClose() function I remove the RTF from the RuntimeStore.

3) In the the DebugMessage function, I add the message to the String, and if the RTF object exists, then the window is created, so I add the new string to it. Otherwise, the debug window is not open so I don't need to worry.

I realize that this is pretty shabby coding, but it works. Any suggestions for improvement?
Offline  
Old 04-15-2005, 01:57 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Sep 2004
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there a reason why you don't want to use the system log?
Offline  
Old 04-15-2005, 02:47 PM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2005
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I suppose there isn't really a "good" reason why I don't just use the system log. However I want to provide the users with a "one-stop-shopping" location to go for the troubleshooting messages. Rather than have to tell them all "Hit Alt-LGLG and tell me what you see", I can have them access my debug menu from my options menu.

This is more intuitive to the user and I have more control over what they are seeing.
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





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