• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difficulty exiting a MIDlet on the WTK20 simulator

 
serge masse
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I don't know if the following is normal behavior on the part of the WTK20 simulator or not, please advise:
My midlet apparently calls notifyDestroyed() ok but the simulator does not display the initial screen where we launch the midlet.
What should be the correct behavior of an exiting midlet on the simulator?
thanks,
serge
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think WTK20 should return to the MIDlet launch screen. What screen did you get?
 
serge masse
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the last screen that my midlet displays stays there and I can still use the menu and go to some other screen. I know that the notifyDestroyed() method is performed because I write in the console to make sure.
based on your answer, I will write a minimal midlet and try to isolate the issue.
will get back with small sample code.
thanks a lot Michael,
serge
 
serge masse
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I fixed the problem. The new code is in the *v.0.7.2* folder in the *File sharing* section of http://leafy.dev.java.net/
I am about 99% sure that the cause of the simulator not exiting the MIDlet into the launch display when performing the *notifyDestroyed()* method was caused by a thread still running in the simulator. It appears that the simulator starts new threads in way still obscure to me. Also, I am not sure if this *new thread creation* behavior is unique to this simulator (v. 2.0_01) or it also occurs in a MIDP2 JRE.
Getting out of a loop that was still running after the *notifyDestroyed()* was performed did the trick.
If I have time, I will publish a small MIDlet that demonstrates this behavior. But it may not be easy, so I am not sure if I will have the time.
In any case, it sure is a nasty cause of strange behavior.
 
serge masse
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This small MIDlet demonstrates that the normal behavior of the *notifyDestroyed()* method is to exit the midlet into the launch display. This MIDlet does not demonstrate the thread creation behavior of the simulator.
 
serge masse
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the demo MIDlet demonstrating the multithreading behavior of the simulator WTK20 that can cause difficulties, such as not exiting properly.
 
serge masse
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above demo MIDlet demonstrating the multithreading behavior
of the simulator WTK20 that can cause difficulties,
such as not exiting properly.

To use:
1) Create a project in the WTK20 simulator (or WTK20_01).
2) Copy this code in the projet *src* folder.
3) Build it.
4) Run it.
5) Use the *Ok* button on the simulated device
to toggle the switch that controls the
loop causing problems. When the switch is true, the loop is stopped
and the MIDlet exits correctly. If false, the loop is not stopped
and the MIDlet does not exit correctly because the loop keeps running
on another thread.

In this demo, the loop runs on the thread that started the MIDlet.
It looks like the simulator calls *actionCommand(c,d)*
method on new threads.
At least in this simulator, the *notifyDestroyed()* method
does not close threads.
I don't know if the JREs in an actual device behave like this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic