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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

How to get phone screen in active call

[ Edited ]

This is a follow-up on Phone menu not shown thread.

 

I have checked with the KB and found an interesting topic: How to - Update a screen on the Main Event Thread

 

My original question (as can be seen in the already mentioned thread) was how to draw something on the Phone screen.

 

Example:

1) A user accepts a call.

2) My app implements PhoneListener and in callConnected() just draws a picture on top of the phone application

3) All the functionalities of the Phone (e.g. Phone menu) are preserved.

 

The mentioned KB article shows that it is possible to draw something on an active screen.

 

How can I get an instance of the Phone screen ?

 

Here is my guess (but it doesn't work) :

  

public void callConnected(int arg0)
{
UiApplication.getUiApplication().invokeLater(new Runnable()
{

public void run()
{
Screen screenName = UiApplication.getUiApplication().getActiveScreen();
//Perform screen changes here.
Graphics g = screenName.getGraphics();
g.setColor(0xFF8080);
g.fillRect(10, 10, 100, 100);
//Calling invalidate() on your screen forces the paint
//method to be called.
screenName.invalidate();
}
});
}

 


How to make getUiApplication() fetch the Phone ?

Message Edited by myraddin on 10-01-2008 04:56 AM


"Listen carefully, I shall say this only once"
Highlighted
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to get phone screen in active call

I even checked Known Issue - Screen.invalidate() does not cause a subsequent call to paint() but with no success Smiley Sad

 

Anyone have an idea what am I doing wrong ?  



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to get phone screen in active call

To stop a torrent of 'you got it all wrong' replies Smiley Happy 
I will admit that I suspect "UiApplication.getUiApplication().invokeLater" is making things go wrong.
 
But is there a way to get currenty active screen? My active screen is (or should be) Phone screen. How can i 'inject' an invokeLater() call into it?


"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to get phone screen in active call

I need to prove myself being wrong while claiming that I was wrong Smiley Happy

 

 

UiApplication application = UiApplication.getUiApplication();

application.invokeLater(new Runnable(){

public void run(){

Screen screenName = UiApplication.getUiApplication().getActiveScreen();

//Perform screen changes here.

Graphics g = screenName.getGraphics();

g.setColor(0xFF8080);

g.fillRect(10, 10, 100, 100);

//Calling invalidate() on your screen forces the paint

//method to be called.

//screenName.doPaint();

screenName.invalidate();

}

}, 1, false );

 

here's the debugger output of two interesting variables (acquired separately, of course)

 

application      @1869E000  net.rim.device.apps.internal.phone.VoiceApp

screenName   @20094000  net.rim.device.apps.internal.phone.ActivePhoneScreen

 

So, the screen I want to modify is the correct one (as well as the application - although I previously didn't check that to be sure - sorry for that) !  

(I even tried using the doPaint() method, but ended up with the same result.)

 

So why isn't the rectangle being drawn on the VoiceApp ?

 



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to get phone screen in active call

Do you ever get the feeling that you are talking to yourself  Smiley Happy ?

 

This is what I needed:

 

//Calling invalidate() on your screen forces the paint

//method to be called.

screenName.updateDisplay();

//screenName.doPaint();

//screenName.invalidate();

 

Why does updateDisplay work, and doPaint (along with its sibling invalidate()) doesn't ? 

 

But, alas, my efforts were futile.

The 'red square' vanishes when something is rePainted over it Smiley Sad This - kinda spoils the fun.

 

So, I guess, my quest continues. 

 

Anyone has any idea how to draw a persistant image on the VoiceApp and still to allow all the VoiceApp features (e.g. menu) ?



"Listen carefully, I shall say this only once"
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get phone screen in active call

paint is protected, you can not access it from outside. would be kind of strange if it would be allowed to paint on foreign screens...
----------------------------------------------------------
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
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to get phone screen in active call

Thanks for the insight, but my code is doing something very similar to that which is considered 'strange' Smiley Happy

 

I would rather paint on my own screen, but I cannot seem to mimic VoiceApp's menu and all so I tried this approach.

 

I hope one of our members will have a clue Smiley Wink

 

Thanks again.

 

 

 



"Listen carefully, I shall say this only once"
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get phone screen in active call

ok, that's an interesting find. next task: write a background application that shows your company name on every screen Smiley Wink
----------------------------------------------------------
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
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to get phone screen in active call

Well, not on EVERY screen Smiley Very Happy  (although even that could be done using my code snippet, and some other snippets - but I still have to resolve flickering)

 

I only want to draw a picture of a caller when in call.

Now isn't that nice Smiley Wink



"Listen carefully, I shall say this only once"
Developer
Posts: 64
Registered: ‎09-02-2008
My Device: 8830, 8100

Re: How to get phone screen in active call

Hi!

 

Just for fun, I tried the code you've written above and when calling I am writting a custom text... below is the code sample, which is basically the same as yours...

 

 

final Screen s = ui.getActiveScreen(); if(s != null){ UiApplication.getUiApplication().invokeLater(new Runnable(){ public void run(){ Graphics g = s.getGraphics(); g.setColor(0x00ffff); int w = s.getWidth(); int h = s.getHeight() >> 1; g.fillRect(0, 0, w, h); g.drawText("Someone calling", w / 2, h / 2, Graphics.TOP | Graphics.LEFT); //s.invalidate(); s.updateDisplay(); } }, 1, false); }

 

When I receive a call, nothing happens... I put some print.outs just to check the code executes and it executed ... Problem is nothing displays on the active phone call screen ...

 

Any idea? s.invalidate() didn't help at all ...

 

Best regards!

gunar