10-01-2008 04:54 AM - edited 10-01-2008 04:56 AM
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 ?
Solved! Go to Solution.
10-01-2008 05:05 AM
I even checked Known Issue - Screen.invalidate() does not cause a subsequent call to paint() but with no success ![]()
Anyone have an idea what am I doing wrong ?
10-01-2008 05:14 AM
10-01-2008 07:13 AM
I need to prove myself being wrong while claiming that I was wrong ![]()
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.ActivePhoneScr
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 ?
10-01-2008 07:30 AM
Do you ever get the feeling that you are talking to yourself
?
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
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) ?
10-01-2008 08:47 AM
10-01-2008 09:02 AM
Thanks for the insight, but my code is doing something very similar to that which is considered 'strange' ![]()
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 ![]()
Thanks again.
10-01-2008 09:30 AM
10-01-2008 09:59 AM
Well, not on EVERY screen
(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 ![]()
10-10-2008 08:19 AM
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