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
Developer
justindutoit
Posts: 405
Registered: ‎05-31-2009
My Device: Not Specified
Accepted Solution

Call-End (red button) produces different behavior

[ Edited ]

Hey. Just a small Q now, mostly my app works great - thanks gents :smileyhappy: - when the user disconnects a phone call, my code first updates the app icon, then shows a dialog.inform box.

 

When testing in the 9000 simulator, if I use the back arrow button to dismiss the dialog box, it works fine and the icon is updated. But when I click the call-end (red button) to dismiss the same dialog.inform box, the icon doesn't update.

 

Any ideas for a workaround, or is there an alternative to Dialog which shows a message and which doesn't have this quirk? I tried using updateDisplay and repaint, but no dice.

 

Tks

Justin.

 

Message Edited by justindutoit on 06-17-2009 01:25 PM
Message Edited by justindutoit on 06-17-2009 01:25 PM
Developer
jhaehnle
Posts: 238
Registered: ‎08-26-2008
My Device: Not Specified

Re: Call-End (red button) produces different behavior

Hi,

 

so why don't switch your application into foreground, not caring about stupid dialogs?

 

Regards,

Jochen

Developer
justindutoit
Posts: 405
Registered: ‎05-31-2009
My Device: Not Specified

Re: Call-End (red button) produces different behavior

Hi- because the app has no UI at this point, it just listens for the end of a phone call, informs the user then calculates and stores new info in persistent storage. The only time people see anything in my app is when they enter settings.

 

Cheers,

Justin

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Call-End (red button) produces different behavior

maybe overwrite dialog and use onUndisplay()? Or register a DialogClosedListener?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
justindutoit
Posts: 405
Registered: ‎05-31-2009
My Device: Not Specified

Re: Call-End (red button) produces different behavior

Hi- I could write some code to run onUndisplay, but what would it be? The code to change the icon is before the Dialog.inform, so shouldn't it have run already... if I change the code so the Dialog.inform isn't run, the icon changes correctly. But the updateIcon is before the Dialog.inform, not after. Does anyone know exactly what the call-end button does in an app?

 

Justin

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Call-End (red button) produces different behavior

in a normal UiApplication the red button calls requestBackground. You can disable this by registering a KeyListener and handing the button.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
justindutoit
Posts: 405
Registered: ‎05-31-2009
My Device: Not Specified

Re: Call-End (red button) produces different behavior

Hi- OK, since I'm a java newbie, I tried the following code. Nothing happens when I press a key- could you please post a working sample of code? :smileyhappy:

Also, how would I simulate pressing of the Escape/Back key instead (so when you press End, it is as if you pressed Escape)?

 

Thanks,

Justin.

 

                   MonthlySpend ms = new MonthlySpend();
                   ms.addKeyListener(new TheKeyListener());
                   // ... etc

 


public static class TheKeyListener implements KeyListener  
{
     public TheKeyListener()
     {
         System.out.println("\n\n\nAdded key listener.\n\n\n");
     }
    
     // Implement methods in the KeyListener interface for handling keyboard events:
     public boolean keyChar(char key, int status, int time)
     {
         if (key == Characters.ENTER)
         {
             System.out.println("\n\n\nPressed Enter\n\n\n");  // End button might be a keycode
         }
        
         return false;
     }
    
     public boolean keyDown(int keycode, int time)
     {
         System.out.println("Keycode is " + String.valueOf(keycode));
         return true;
     }
 
     public boolean keyRepeat(int keycode, int time)
     {
         return true;
     }
    
     public boolean keyStatus(int keycode, int time)
     {
         return true;
     }
    
     public boolean keyUp(int keycode, int time)
     {
         return true;
     }   
}

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Call-End (red button) produces different behavior

use
protected boolean keyDown(int keycode, int time)

the keycodes for the green key is 1114112, the red key is 1179648
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
justindutoit
Posts: 405
Registered: ‎05-31-2009
My Device: Not Specified

Re: Call-End (red button) produces different behavior

[ Edited ]

Thanks, I tried adding the KeyListener in a different place and it works now!

 

Cheers,

Justin

 

Message Edited by justindutoit on 06-19-2009 10:32 AM
Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: Call-End (red button) produces different behavior

Hi justindutoit and everyone
                    hey i have a similar kind of Question well i have to disable the Call Button, Call End Button and Back Button when a alert from background appears on the screen the alert is able to happen but at that time i want only the Track Ball to Work and remaining all the Buttons mentioned above should be disables.....can u pls guide me regarding this...or can u pls tell me the Key Code to Call Button, Call End Button and Back Button.....