I have an app which saves data on the rms on a particular time basis. This is handled by a Timer/TimerTask combo and is scheduled to execute every 5 secs...
The idea is to save some data in case the feared "red button" is accidentally pushed.
It al seems to work but now I encountered a problem, if the "red button" is pressed (in the emulator) the midlet is shut down but the wtk emulator still keeps running (just like a real phone, and my testbed a Nokia N95) I noticed the thread keeps running (and thus keeps writing to the RMS). I know this because I let it write some text to the output stream.
I am wondering how this is possible ? And how do I stop it ?
The second problem is that this thread also updates a variable in my main Midlet.
Obviously my main midlet object is destroyed once the red button is pressed. Then I restart my midlet, and the rms-saving Timer object still has the old reference to the old midlet, also the midlet creates a new rms-saving Timer thread because it doesnt recognize the already existing (out of his midletsuite) thread, this isnt a object created by the midlet at that moment in time so why should it recognize it ?
Does this sound familiar to anyone or does anyone have some tips ? I tried it on a real device also but having no output stream I actuallly dont know how it behave,s I do know that after restarting the midlet the variable in the midlet will NOT be updated anymore...