Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

pauseApp() MIDLet what is appropriate to keep active.

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.
Developer
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Re: pauseApp() MIDLet what is appropriate to keep active.

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();
    }

}

 

BlackBerry Development Advisor
Posts: 15,724
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: pauseApp() MIDlet what is appropriate to keep active.

Note that if you were to change the application from a MIDlet to a BlackBerry CLDC application you would have the ability to run the application in the background and keep it running indefinitely.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Highlighted
Developer
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Re: pauseApp() MIDLet what is appropriate to keep active.

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.