Forums Register Login

MIDP Canvas problem!!!

+Pie Number of slices to send: Send
Hi, Thank you for taking your time in advance.
I am working on MIDP project current. Basically, 3 thread are running: main MIDlet, animaion, Httpconnection. Animation class is a Canvas, I use showNotify() and hideNotify to control the animation image (i.e. start or stop the animation). When i click a menu, the request will be sent out and in the meantime, the animation canvas will show up with animation running to hide the network delay. Upon response from the server comming a Alert needed to show on screen replacing the animation. But it doesn't work, the anim canvas even does not be shown (which mean showNotify() never been called). if I comment the Alert, the anim canvas can work well.
what the problem, please give me some help! Any tricky way to do that?THanks a lot.
+Pie Number of slices to send: Send
 

Originally posted by Gang Lu:
Hi, Thank you for taking your time in advance.
I am working on MIDP project current. Basically, 3 thread are running: main MIDlet, animaion, Httpconnection. Animation class is a Canvas, I use showNotify() and hideNotify to control the animation image (i.e. start or stop the animation). When i click a menu, the request will be sent out and in the meantime, the animation canvas will show up with animation running to hide the network delay. Upon response from the server comming a Alert needed to show on screen replacing the animation. But it doesn't work, the anim canvas even does not be shown (which mean showNotify() never been called). if I comment the Alert, the anim canvas can work well.
what the problem, please give me some help! Any tricky way to do that?THanks a lot.


Can you paste the code that you use to call the canvas and the alert? It may help figure out the problem.
Also, what thread are you making the calls from?
+Pie Number of slices to send: Send
Thanks a lot. Here is the procedure:
1. in Login Screen,when user input the username & password and click Signin menu,HTTP connection will established and doAuthenticate();
private void doAuthenticate() throws IOException {
....
// call HTTP connection Thread
httpPoster.sendRequest(....);
// set the animScreen to run the animation
Display.getDisplay(mMIDlet).setCurrent(mMIDlet.animScreen);
try {
synchronized (mMIDlet) {
// block the MIDlet thread and wait for the authentication result from the server.
mMIDlet.mMIDletBlocked = true;
mMIDlet.wait();
}
} catch (Exception e) {
.....
}
}
2. the animation is controled by showNotify()->(start anim) and hideNotify()->(stop anim). When the reponse from server is catched, the MIDlet will be notified and a Alert will be called to notice the user the result. here is the method in MIDlet class called when the response catched:
public void authenticationDone() {
infoScreen = new InfoScreen(this, httpPoster);
Display.getDisplay(this).setCurrent(infoScreen);
}
3.in Animation Screen class, here are the showNotify():
protected synchronized void showNotify() {
System.out.println("Animation Screen Canvas is Showing!");
if ( image == null ) {
for (int i=0; i < numFrames; i++)
{
try
{
image = Image.createImage("/frame_" + (i+1) +".png");
imageArray[ i ] = image;
} catch (IOException ioe)
{
System.out.println("IO Error while getting the PNG image!");
}
}
imageHSize = imageArray[0].getWidth();
imageVSize = imageArray[0].getHeight();
mMessage = null;
}
running = true;
new Thread(this).start();
}
Any other codes you need to clarify my question?
Many Thanks.
+Pie Number of slices to send: Send
Gang,
Unless I missed it in your code, why not use an actual Alert object to display the alert?
Once you create your Alert, you can display the Alert and then the Canvas like so:

See if that helps.
[ August 19, 2003: Message edited by: Frank Manno ]
+Pie Number of slices to send: Send
Thanks a lot.
I create a simple Alert and call Display.setCurrent(alert, animScreen) right after midlet thread catching the reponse. Unfortunately, it does not work. Any other idea I could try? I am so desperate. Do you have any example code?
Many thanks.
+Pie Number of slices to send: Send
I use println() in ShowNotify() in animScreen. I thought if i call Display.setCurrent(animScreen) this ShowNotify() will be called. But it does not when the setCurrent(alert, animScreen) followed by it. If I comment out the setCurrent(alert, animScreen), ShowNotify() is called and animation Screen is running.
+Pie Number of slices to send: Send
Gang,
Would you mind posting some more of the code... I can't seem to pinpoint the problem... Also, be sure to enclose your code within "[ code ][ /code ]" blocks (be sure to remove the extra spacing between the words and the braces), so that it makes it easier to read it.
+Pie Number of slices to send: Send
Thanks. Here is my code:
1. LoginScreen is used for input username and password

here is doAuthenticate() codes

2. receiveHttpResonse() is uesed to process the response from server

3. The problem is that if these two lines are used after
Display.getDisplay(mMIDlet).setCurrent(mMIDlet.animScreen) :

the animation canvas cannot be shown. If i remove them, the animation can be seen and working well.
please see previous post for detail about animation canvas.
What's the problem? Is my explain clear? Thanks a lot indeed.

[ August 21, 2003: Message edited by: Gang Lu ]
[ August 21, 2003: Message edited by: Gang Lu ]
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2157 times.
Similar Threads
High leve UI& Low level UI confusing
Help Needed on animation in j2me
Handling hideNotify/showNotify
Newbie: End app after alert
What happened to my Canvas when callSerially
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:42:01.