09-03-2008 11:53 AM
I have an application that periodiclly polls for data every five minutes using Thread.sleep(),
After a long run on a 8110 I assume pauseApp() is being called at somepoint by the system.
I don't want this app to pause so how do I say safely say I need to continue? I am sure I can
try different things but it is quite difficult to experiment with. My immediate thought is to
call resumeRequest() from the pauseApp() but I do not want to get into a loop.
So what is appropriate.09-03-2008 01:41 PM
I have decided to periodically kick the MIDlet to resume using this code
below. The situation is that the 8110 is running this midlet for about four hours noone
is touching the phone and it decides to pause the App (hibernate I assume) so why not kick it back to resume.
Is this appropriate? I am sure it would work fine for a Phone call coming in too since the system will
decide if the midlet should resume (it is periodically asking). You see the pauseApp() is called and a period
timer is created to ask for resume. Seems to work.
class MyTimerTask extends TimerTask {
tbsmMidlet m;
public MyTimerTask(tbsmMidlet m){
this.m=m;
}
public void run(){
((MIDlet)m).resumeRequest();
}
}
public class myMidlet extends MIDlet {
Timer t=null;
:
:
:
public void startApp() {
if (t!=null)
t.cancel();
t=null;
Toolkit.setCurrent(this,sf);
wdmi.start();
}
public void pauseApp() {
if (tbsmSpec.refresh.equals("0")==false) { //periodically kick ourselves to be alive
t = new Timer();
t.schedule(new MyTimerTask(this),0,5000);
}
}
public void destroyApp(boolean unconditional) {
if (t!=null)
t.cancel();
:
notifyDestroyed();
}
}
09-04-2008 12:00 PM
09-04-2008 01:24 PM
I would do that (convert toe BB CLDC) but the JDE is a great barrier lets say, too much confusion to how to use it,
I decided to use the Timer as my scheduler. I might explore the BB JDE for the fourth time.