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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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,885
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.
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.