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
New Developer
Posts: 18
Registered: ‎09-03-2008
My Device: Not Specified
Accepted Solution

Dialog.show() not showing

Hi all,

 

I've looked through the forum for a solution but haven't been able to find one. I have a screen (inherited from Screen), on which a new Dialog I've created is not showing when I call show(). Dialog.alert() shows a dialog just fine, so does Dialog.ask(). If I call doModal() on the new dialog, that shows it just fine. It's only show() which doesn't work.

 

Note that I use Dialog.show() in lots of other screens in my app, and that works without a problem. I've examined my Screens to see what's different about them, but nothing I've found explains why the Dialogs aren't showing.

 

I've tried, immediately after the .show(), closing the Screen, so I could see if the Dialog popped up behind the Screen, but no luck there. I've also called .show(Dialog.GLOBAL_STATUS), but that didn't help.

 

The code I'm using to show is:

 

Object[] choices = {new LabelField("DoSomething")};

Dialog d = new Dialog("Showing a dialog...", choices, null, 0, new Bitmap(0,0));

d.setDialogClosedListener(... blah blah blah...);

UiApplication.UiApplication().invokeLater(new Runnable() { public void run() {

    d.show();

}});

 

Any ideas would be appreciated. Thanks!

 

Steve

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

Re: Dialog.show() not showing

If you put a breakpoint in, is the show executed?

New Developer
Posts: 18
Registered: ‎09-03-2008
My Device: Not Specified

Re: Dialog.show() not showing

Thanks for your reply, Peter.

 

I rarely use breakpoints, so I assume what you're talking about would be equivalent to doing

 

<with the ui thread>

d.show();

System.out.println("Got this far!");

 

In that case, yes, I've verified that the call is running (by setting a breakpoint on a noop right after the show() call, and by logging out stdout.)

 

In the debugger, should I be looking for anything helpful inside the Dialog object to indicate whether it's been run properly?

 

Steve

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

Re: Dialog.show() not showing

From where are you calling that code (separate thread, constructor for a screen, navigationClick method, etc...)?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 18
Registered: ‎09-03-2008
My Device: Not Specified

Re: Dialog.show() not showing

Hi Mark, thanks for your reply.

 

This code sits inside a function that is called either by ButtonField.keyDown() or ButtonField.trackwheelClick().

 

Steve

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

Re: Dialog.show() not showing

What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

 

Does Dialog.doModal work?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 18
Registered: ‎09-03-2008
My Device: Not Specified

Re: Dialog.show() not showing

Yes, doModal() does work.

 

I've tested it on both JDE 4.5.0 and on an actual device running 5.0.0.714 (platform 5.1.0.146).

 

Steve

New Developer
Posts: 18
Registered: ‎09-03-2008
My Device: Not Specified

Re: Dialog.show() not showing

Whoops, forgot to mention that the physical device is a 9700. On the simulator I tend to use the 8320.

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

Re: Dialog.show() not showing

I recall there was an obscure issue with the show method in some versions of 5.0... but can't recall the details right now.  The work around was to use doModal instead. 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 18
Registered: ‎09-03-2008
My Device: Not Specified

Re: Dialog.show() not showing

Hi Mark and Peter,

 

I managed to narrow the problem down to a short bit of test code. Though the cause of this problem isn't obvious to me, I won't be surprised if it is to you. :-) I'm running this in 4.5, but as noted above, the problem in my main app was resistant to changes in simulator version.

 

Note that I've tried it with a non-empty set of choices, but no luck there either. Hope you can give this a look. Thanks!

 

Steve